Created
May 4, 2013 15:10
-
-
Save anonymous/5517761 to your computer and use it in GitHub Desktop.
Jquery validation script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() | |
{ | |
$("#registermail").validate({ | |
rules: { | |
'email':{ | |
required: true, | |
email: true, | |
remote: "/incontri/validate/validate_mail.php" | |
}, | |
'username':{ | |
required: true, | |
minlength: 6, | |
maxlength: 20, | |
remote: "/incontri/validate/validate_user.php" | |
}, | |
'password':{ | |
required: true, | |
minlength: 6, | |
maxlength: 20 | |
}, | |
'verify_password':{ | |
required: true, | |
minlength: 6, | |
maxlength: 20, | |
equalTo: "#password" | |
}, | |
'provincia':{ | |
required: true, | |
minlength: 1 | |
}, | |
'genere':{ | |
required: true, | |
minlength: 1 | |
}, | |
'orientamento':{ | |
required: true, | |
minlength: 1 | |
}, | |
'annuncio':{ | |
required: true, | |
minlength: 120 | |
}, | |
'contact_photo':{ | |
required: true | |
} | |
}, | |
messages: | |
{ | |
'username':{ | |
required: "My alert message", | |
minlength: "My alert message", | |
remote: jQuery.validator.format("My alert message") | |
}, | |
'email':{ | |
required: "My alert message", | |
email: "My alert message", | |
remote: jQuery.validator.format("My alert message") | |
}, | |
'password':{ | |
required: "My alert message", | |
minlength: "My alert message" | |
}, | |
'verify_password':{ | |
required: "My alert message", | |
minlength: "My alert message", | |
equalTo: "My alert message" | |
}, | |
'provincia':{ | |
required: "My alert message", | |
minlength: "My alert message" | |
}, | |
'genere':{ | |
required: "My alert message", | |
minlength: "My alert message" | |
}, | |
'orientamento':{ | |
required: "My alert message", | |
minlength: "My alert message" | |
}, | |
'annuncio':{ | |
required: "Senza il tuo annuncio non verrai mai contattato...", | |
minlength: "Compila almeno 120 caratteri" | |
}, | |
'contact_photo':{ | |
required: "Inserisci la tua immagine" | |
} | |
}, | |
errorLabelContainer: ".errorBox", | |
submitHandler: function(form) { | |
$("#register_submit").attr('value','Attendi...'); | |
$("#register_submit").attr('disabled', 'disabled'); | |
$('.breast_img').addClass("breast_green"); | |
$.ajax({ | |
url: "/incontri/validate/submit.php", | |
type: "POST", | |
data: $("#registermail").serialize(), | |
success: function(e) { | |
e.preventDefault; | |
$("#register_submit").attr('disabled', 'disabled'); | |
$("#register_submit").attr('value','Grazie!'); | |
$('div.successBox').fadeIn('fast'); | |
$('.errorBox').fadeOut(); | |
//validator.resetForm(); | |
}, | |
error: function(){ | |
console.log('Problemi'); | |
} | |
}); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment