https://jumnuoy.blogspot.com/2013/12/jquery-validation-how-to-validade.html
From:
<form id="myform">
<input type="text" name="Generated1" class="MyRule" />
<input type="text" name="Generated2" class="MyRule" />
<br/>
<input type="submit" />
</form> Javascript:
<form id="myform">
<input type="text" name="Generated1" class="MyRule" />
<input type="text" name="Generated2" class="MyRule" />
<br/>
<input type="submit" />
</form> Javascript:
<script>
$(document).ready(function () {
$.validator.addClassRules("MyRule", {
required: true
});
$('#myform').validate({
submitHandler: function (form) { // for demo
alert('submitted'); // for demo
return false; // form demo
}
});
});
</script>
demo
Jquery.validate - one Page - multiple forms
<form action="" method="post" class="form-horizontal" id="formA">
<input type="text" name="name1" class="required" />
<button id="formASend" type="submit" class="btn">Submit</button>
</form>
<form action="" method="post" class="form-horizontal" id="formB">
<input type="text" name="name2" class="required" />
<button id="formBSend" type="submit" class="btn">Submit</button>
</form>
<form action="" method="post" class="form-horizontal" id="formC">
<input type="text" name="name3" class="required" />
<button id="formCSend" type="submit" class="btn">Submit</button>
</form>
$(document).ready(function()demo with multi-form
{
$.validator.addClassRules('required', {
required: true
});
$('#login').validate();
$('#register').validate();
});
From:
<form id="myform">
<input type="text" name="Generated1" class="MyRule" />
<input type="text" name="Generated2" class="MyRule" />
<br/>
<input type="submit" />
</form> Javascript:
<script>
$(document).ready(function () {
$.validator.addClassRules("MyRule", {
required: true
});
$('#myform').validate({
submitHandler: function (form) { // for demo
alert('submitted'); // for demo
return false; // form demo
}
});
});
</script>
demo
Jquery.validate - one Page - multiple forms
<form action="" method="post" class="form-horizontal" id="formA">
<input type="text" name="name1" class="required" />
<button id="formASend" type="submit" class="btn">Submit</button>
</form>
<form action="" method="post" class="form-horizontal" id="formB">
<input type="text" name="name2" class="required" />
<button id="formBSend" type="submit" class="btn">Submit</button>
</form>
<form action="" method="post" class="form-horizontal" id="formC">
<input type="text" name="name3" class="required" />
<button id="formCSend" type="submit" class="btn">Submit</button>
</form>
$(document).ready(function()demo with multi-form HTML javascript Jquery
{
$.validator.addClassRules('required', {
required: true
});
$('#login').validate();
$('#register').validate();
});
0 comments:
Post a Comment