Reputation: 1
I am Using jQuery Validation Plugin 1.8.1.Here my Web form contains various controls like Text box, dropdown List ,User Controls etc. Each control has validations (Required fields, Emails)
input id="email" name="email" class="{validate:{required:true,email:true}}"
Now my page has Save & Submit button, here as per the requirement if the user clicks on save button the user would able to save the form (incomplete form also) , in this case user should not be prompted for required field(if he is leaving any).The data would save as Draft he may re-continue later but if he Clicks on Submit all validations as tagged with each controls would apply.
<script type="text/javascript">
$().ready(function () {
$.validator.setDefaults({
invalidHandler: function (form, validator) { }
});
var container = $("div.container");
$("#form1").validate({
errorContainer: container,
errorLabelContainer: $("ul", container),
wrapper: 'li',
meta: "validate"
});
});
</script>
Above is the Base validation method written in Master Page. Any idea how to achieve this???
Upvotes: 0
Views: 652
Reputation: 1444
For the save button simply set the class to "cancel" instead of "submit". This will skip the validation.
Answer can be seen here:
jQuery validate(); Only validate on click of one type of submit button
http://docs.jquery.com/Plugins/Validation/Reference#Skipping_validation_on_submit
Upvotes: 0