Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

how to validate multipage form? #8

Open
rw1 opened this issue Oct 8, 2012 · 0 comments
Open

how to validate multipage form? #8

rw1 opened this issue Oct 8, 2012 · 0 comments

Comments

@rw1
Copy link

rw1 commented Oct 8, 2012

hello,

can anyone tell me how the multipage form can be validated ie prevent the user from going to the next page or submitting the form if fields are not valid?

i've downloaded jquery validate and followed instructions here:

http://alittlecode.com/files/jQuery-Validate-Demo/

i have managed to get validation working 'onblur' but you have to click in the field first.

the problem is it is still possible to navigate through all the pages and click submit.

i would like to prevent the user from moving forward if the page does not validate.

here is head code:

<script type="text/javascript" src="http://path.to/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="http://path.to/jquery.validate.min.js"></script>
<!-- validation -->
<script type="text/javascript">
$(document).ready(function(){
$('#multipage').validate(
{
onfocusout: function(element) { jQuery(element).valid(); } , // enables onblur validation
rules: {
name: {
minlength: 2,
required: true
},
email: {
required: true,
email: true
},
message: {
minlength: 2,
required: true
},
message_2: {
minlength: 2,
required: true
}
},
messages: {
name: "please enter your name",
email: {
required: "please enter your email",
email: "please enter a valid email"
},
message: "please enter your message",
message_2: "please enter your second message"
},
highlight: function(label) {
$(label).closest('.control-group').addClass('error');
},
success: function(label) {
label
.text('OK!').addClass('valid')
.closest('.control-group').addClass('success');
}
});
});
</script>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant