I have a form that generates a text box when the user selects "others" in the drop-down list.
The dynamic generation of the text field was created, and I can get the value of the text field "others".
But my problem
1) I want to check the contents of the text box when it was shown.
How to validate any offers.
<form name="f2" id="f2" method="post" action="" enctype="multipart/form-data">
Type:
<select name="type" id="type" onchange='CheckColors(this.value);'>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="others">others</option>
</select>
<input type="text" name="others" id="others" style='display:none;'/>
<input type="submit" name="submit"/>
</form>
// Here is a script to validate the form. I want to check another text box when it appears only ... How to do this?
<script type = "text/javascript">
$(document).ready(function () {
$("#f2").validate({
debug: false,
rules: {
type: {
required: true
},
others: {
required: true
},
messages: {
}
});
});
</script>
I tried the process described above, but it always shows that they were served twice side by side.
source
share