1
I have an ASP.NET form and am using jQuery Validate to apply validation rules in the fields. All my fields have a common rule (required: true
) but I couldn’t find a way to apply it all at once.
$('#form1').validate({
rules: {
'<%= txtRazaoSocial.UniqueID %>': {
required: true
},
'<%= txtNomeFantasia.UniqueID %>': {
required: true
},
'<%= txtCNPJ.UniqueID %>': {
required: true,
cnpj: true
},
'<%= txtCEP.UniqueID %>': {
required: true
},
'<%= txtLogradouro.UniqueID %>': {
required: true
},
'<%= txtNumeroLogradouro.UniqueID %>': {
required: true
},
'<%= txtBairro.UniqueID %>': {
required: true
[...]
This problem can be solved?
EDIT: I tried the way below too, but it didn’t work.
$('#form1').validate({
rules: {
required: true,
},
Add the required class to all Fields
– Diego Vieira