I have a form in ASP.NET and I'm using jQuery Validate to apply validation rules in the fields. All my fields have a common rule ( required: true
) but I could not find a way to apply this to 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
[...]
Can this problem be solved?
EDIT: I tried the below as well, but it did not work.
$('#form1').validate({
rules: {
required: true,
},