I have a form when the submit button is clicked form's all inputs needs to be in read-only mode and hide submit button and also displays submitting text. For this I coded:
$(document).ready(function() {
$("#submit_text").hide(); //Hiding submit_text
$("#testsubmitbutton").click(function() {
$("#testsubmitbutton").hide(); //Hiding submit button
$("#submit_text").show(); //Showing submit_text
$("#testform :input").prop('readonly', true); //Making all inputs to readonly
});
});
.hiddenFramehideclass {
position: absolute;
top: -1px;
left: -1px;
width: 1px;
height: 1px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<iframe name="hiddenFrame" class="hiddenFramehideclass"></iframe>
<form method="post" action="" enctype="multipart/form-data" id="testform" target="hiddenFrame">
Question 1
<div class="question_container">
<div class="question_div">
<p>Question?</p>
<input type="hidden" name="qid1" value="22">
<div class="option_div">
<input type="radio" name="radio1" id="checka1" value="A">
<label for="checka1">
<p>A</p>
</label>
</div>
<div class="option_div">
<input type="radio" name="radio1" id="checkb1" value="B">
<label for="checkb1">
<p>B</p>
</label>
</div>
<div class="option_div">
<input type="radio" name="radio1" id="checkc1" value="C">
<label for="checkc1">
<p>C</p>
</label>
</div>
<div class="option_div">
<input type="radio" name="radio1" id="checkd1" value="D">
<label for="checkd1">
<p>D</p>
</label>
</div>
<div class="option_div">
<input type="radio" name="radio1" id="checke1" value="E">
<label for="checke1">
<p>None of the above</p>
</label>
</div>
</div>
</div>
<button class="" type="submit" name="testsubmitbutton" id="testsubmitbutton">Submit</button>
<span id="submit_text">Submitting please <b>do not</b> refresh!</span>
</form>
When I click the submit button it hides the submit button and shows submitting text. But it doesn't change the input property to read-only mode.