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

how to validate multipage form? #8

Description

@rw1

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>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions