Hi Rajivgandhi,
Thanks for contacting Syncfusion Support.
In order to validate dropdownlist using jQuery validation plugin, you need to set defaults for the validator. Refer to the following code snippet.
$.validator.setDefaults({
ignore: [], // To include hidden input in validation
errorClass: 'e-validation-error', // To get the error message on jquery validation
errorPlacement: function (error, element) {
$( element ).closest( "form" )
.find( "label[for='" + element.attr( "id" ) + "']" ).append( error );
} // To place the error message on required element
}); |
Note: To include dropdownlist in validation, you have to clear the ignore in setDefaults because by default in jQuery validation the hidden inputs are ignored from validation and our dropdownlist has the input element hidden.
Set the rules for validation.
$("form[id='details']").validate({
rules: {
field: {
required: true // Rules for textbox
},
drpdwn: {
required: true // Rules for Dropdownlist
}
},
}); |
The Textbox and Dropdownlist will be validated on form submit. To validate on button click use form valid method.
function onClick(){
$("form[id='details']").valid();
} |
Regards,
Prince