javascript form validation - positioning
Posted
by Holian
on Stack Overflow
See other posts from Stack Overflow
or by Holian
Published on 2010-03-16T09:01:44Z
Indexed on
2010/03/16
9:06 UTC
Read the original article
Hit count: 541
Dear Masters!
I have little snippet for validatin' my form. I need help to position the error messages, because now all message appear in the filed, so the user can't see it, and so its very annoying.
$(document).ready(function() {
jQuery.validator.addMethod("lettersonly", function(value, element) {
return this.optional(element) || /^[a-zoöüóúéáuí ]+$/i.test(value);
}, "<?php echo $lettersonly; ?>");
$("#regval").validate({
rules: {
name: {
required: true,
minlength: 5,
maxlength:30,
lettersonly: true
},
nick: {
required: true,
minlength: 3,
maxlength:12
},
pass1: {
required: true,
minlength: 5
},
pass2: {
required: true,
minlength: 5,
equalTo: "#pass1"
},
messages: {
full: {
required: ".....",
minlength: "....",
maxlength: "...."
},
nick: {
required: "....",
minlength: "....",
maxlength: "...."
},
pass1: {
required: "....",
minlength: "..."
},
pass2: {
required: "....",
minlength: "....",
equalTo: "...."
},
});
});
</script>
© Stack Overflow or respective owner