Hi,
I have a button:
<input class = "save" type="button" value="Išsaugoti" />
As you can see the type is not submit, it is just button. This is because I want to not allow submission if javascript is disabled.
To submit I run this code:
$('input.save').click(function() {
$('form').attr( 'target', '' );
$(".edit").validate({
rules: {
input_pavadinimas: {
required: true,
maxlength: 20
},
text: {
required: true
}
},
messages: {
input_pavadinimas:{
required: "Neįvedėte pavadinimo",
maxlength: "Maksimalus ilgis - 20 simbolių"
},
text: {
required: "Neįvedėte teksto"
}
}
}
);
document.myform.submit(); //myfor - formos name atributas
});
But the validation doesn't work.
When the button type is submit and I run this code
$(".edit").validate({
submitHandler:function(form) {
form.submit();
//document.myform.submit(); //myfor - formos name atributas
},
rules: {
input_pavadinimas: {
required: true,
maxlength: 20
},
text: {
required: true
}
},
messages: {
input_pavadinimas:{
required: "Neįvedėte pavadinimo",
maxlength: "Maksimalus ilgis - 20 simbolių"
},
text: {
required: "Neįvedėte teksto"
}
}
});
validation works perfectly.
I don't find in google and in documentation how to run it when button is not submit type :( Can you help me?