I am using a jquery form wizard for my form, it is a multiple page form, example below:
http://thecodemine.org/examples/example_1_straight.html
The form is using a jquery validation plugin, & in the jquery.validation.js , there is no validation rule for password or to check retype password.
I tried many other simple verification form codes, but they don’t work with form wizard, it may be because as this is the multiple page form, & it doesn’t pass the information when I click on next button
If I use mootools to verify then jquery form wizard stop doing work.
I am trying to use the simple code mentioned after a small customization, but it also doesn’t work on the form either, however it works on other simple forms.
Kindly guide me on how can I use this script in my page, which is exactly similar with the example on the above mentioned link.
First I call pass the values to form wizard to create the animated form, code mentioned below
<script type="text/javascript">
$(function(){
$("#SignupForm").formwizard({
formPluginEnabled: true,
validationEnabled: true,
focusFirstInput : true,
formOptions :{
success: function(data){$("#status").fadeTo(500,1,function(){ $(this).html("You are now registered!").fadeTo(5000, 0); })},
beforeSubmit: function(data){$("#data").html("data sent to the server: " + $.param(data));},
dataType: 'json',
resetForm: true
}
}
);
});
</script>
Below is the verification code which I am trying to use in the form, but it doesn’t work
<script type="text/javascript">
$(function(){
var pass1 = $('#password'),
pass2 = $('#passwordConfirm'),
email = $('#email'),
form = $('#SignupForm'),
strength = $('#strength'),
arrow = $('#form-div .arrow');
// Empty the fields on load
$('#main .row input').val('');
// Handle form submissions
form.on('submit',function(e){
// Is everything entered correctly?
if($('#main .row.success').length == $('#main .row').length){
// Yes!
alert("Thank you for trying out this demo!");
e.preventDefault(); // Remove this to allow actual submission
}
else{
// No. Prevent form submission
e.preventDefault();
}
});
// Validate the email field
email.on('blur',function(){
// Very simple validation
if (!/^\S+@\S+\.\S+$/.test(email.val())){
email.parent().addClass('error').removeClass('success');
}
else{
email.parent().removeClass('error').addClass('success');
}
});
// Use the complexify plugin on the first password field
pass1.complexify({minimumChars:7, strengthScaleFactor:0.4}, function(valid, complexity){
if(valid){
pass2.removeAttr('disabled');
pass1.parent()
.removeClass('error')
.addClass('success');
}
else{
pass2.attr('disabled','true');
pass1.parent()
.removeClass('success')
.addClass('error');
}
var calculated = (complexity/100)*268-30;
if(calculated <50){
$('#strength').text('Very Weak');
strength.removeClass('GreenJoy').addClass('RedWarn');
}
if(calculated >50 && calculated < 100){
$('#strength').text('Weak');
strength.removeClass('GreenJoy').addClass('RedWarn');
}
if(calculated >100 && calculated < 150){
$('#strength').text('Normal');
strength.removeClass('RedWarn').addClass('GreenJoy');
}
if(calculated >170 && calculated < 200){
$('#strength').text('Good');
strength.removeClass('RedWarn').addClass('GreenJoy');
}
if(calculated >235){
$('#strength').text('Perfect!');
strength.removeClass('RedWarn').addClass('GreenJoy');
}
});
// Validate the second password field
pass2.on('keydown input',function(){
// Make sure its value equals the first's
if(pass2.val() == pass1.val()){
pass2.parent()
.removeClass('error')
.addClass('success');
}
else{
pass2.parent()
.removeClass('success')
.addClass('error');
}
});
});
</script>
I got it:)
there is a validation rule equalTo in jquery.validate.js
i do this to get password velidation
HTML
JavaScript