Revision: 51196
Updated Code
at September 16, 2011 16:46 by haidaica
Updated Code
<!--<div id="errorbox"><ul></ul></div>-->
$(document).ready(function(){
$("#commentForm").validate({
errorContainer: "#errorbox",
errorLabelContainer: "#errorbox ul",
wrapper: "li",
rules: {
name: "required",
email: {
required: true,
email: true,
},
comment: "required"
},
messages: {
comment: "This is a comment form. Why in the heck would you leave the comment blank?",
email: {
required: "Email address is required.",
email: "Email addresses are of the form user@host. Not yourRstupid."
},
name: {
required: "Stand up for your comments or go home."
}
}
});
});
//
$(document).ready(function(){
$("#commentForm").validate({
rules: {
name: {
required: true,
minlength: 2
},
email: {
required: "#csub:checked",
email: true,
},
comment: "required"
},
messages: {
comment: "This is a comment form. Why in the heck would you leave the comment blank?",
email: {
required: "Dude, you want the newsletter, but you didn't enter an email address?",
email: "Email addresses are of the form user@host. Not yourRstupid."
},
name: {
required: "Stand up for your comments or go home.",
minlength: jQuery.format("You need to use at least {0} characters for your name.")
}
}
});
});
//
$(document).ready(function(){
$.validator.addMethod("noanon", function(value) {
return value.toLowerCase().indexOf("anonymous") != 0;
}, 'Do not hide behind the cover of anonymity');
$("#commentForm").validate({
rules: {
name: {
required: true,
minlength: 2,
noanon: true
},
email: {
required: "#csub:checked",
email: true,
},
comment: "required"
},
messages: {
comment: "This is a comment form. Why in the heck would you leave the comment blank?",
email: {
required: "Dude, you want the newsletter, but you didn't enter an email address?",
email: "Email addresses are of the form user@host. Not yourRstupid."
},
name: {
required: "Stand up for your comments or go home.",
minlength: jQuery.format("You need to use at least {0} characters for your name.")
}
}
});
});
//
<tr>
<td>Phone</td>
<td><input name="phone" type="text" id="phone" class="required NumbersOnly"></td>
</tr>
<script>
$(document).ready(function(){
$.validator.addMethod("NumbersOnly", function(value, element) {
return this.optional(element) || /^[0-9\-\+]+$/i.test(value);
}, "Phone must contain only numbers, + and -.");
$("#regForm").validate();
});
</script>
<script>
$(document).ready(function(){
$.validator.addMethod("username", function(value, element) {
return this.optional(element) || /^[a-z0-9\_]+$/i.test(value);
}, "Username must contain only letters, numbers, or underscore.");
$("#regForm").validate();
});
</script>
Finally, i somehow got hold of the code that does the job through regular expression regex that checks for only numbers and a-z
1
2
3
4
5
6
7
8
9
10
<script>
$(document).ready(function(){
$.validator.addMethod("noSpecialChars", function(value, element) {
return this.optional(element) || /^[a-z0-9\_]+$/i.test(value);
}, "Username must contain only letters, numbers, or underscore.");
$("#myForm").validate();
});
</script>
Revision: 51195
Updated Code
at September 16, 2011 16:45 by haidaica
Updated Code
<!--<div id="errorbox"><ul></ul></div>-->
$(document).ready(function(){
$("#commentForm").validate({
errorContainer: "#errorbox",
errorLabelContainer: "#errorbox ul",
wrapper: "li",
rules: {
name: "required",
email: {
required: true,
email: true,
},
comment: "required"
},
messages: {
comment: "This is a comment form. Why in the heck would you leave the comment blank?",
email: {
required: "Email address is required.",
email: "Email addresses are of the form user@host. Not yourRstupid."
},
name: {
required: "Stand up for your comments or go home."
}
}
});
});
//
$(document).ready(function(){
$("#commentForm").validate({
rules: {
name: {
required: true,
minlength: 2
},
email: {
required: "#csub:checked",
email: true,
},
comment: "required"
},
messages: {
comment: "This is a comment form. Why in the heck would you leave the comment blank?",
email: {
required: "Dude, you want the newsletter, but you didn't enter an email address?",
email: "Email addresses are of the form user@host. Not yourRstupid."
},
name: {
required: "Stand up for your comments or go home.",
minlength: jQuery.format("You need to use at least {0} characters for your name.")
}
}
});
});
//
$(document).ready(function(){
$.validator.addMethod("noanon", function(value) {
return value.toLowerCase().indexOf("anonymous") != 0;
}, 'Do not hide behind the cover of anonymity');
$("#commentForm").validate({
rules: {
name: {
required: true,
minlength: 2,
noanon: true
},
email: {
required: "#csub:checked",
email: true,
},
comment: "required"
},
messages: {
comment: "This is a comment form. Why in the heck would you leave the comment blank?",
email: {
required: "Dude, you want the newsletter, but you didn't enter an email address?",
email: "Email addresses are of the form user@host. Not yourRstupid."
},
name: {
required: "Stand up for your comments or go home.",
minlength: jQuery.format("You need to use at least {0} characters for your name.")
}
}
});
});
//
<tr>
<td>Phone</td>
<td><input name="phone" type="text" id="phone" class="required NumbersOnly"></td>
</tr>
<script>
$(document).ready(function(){
$.validator.addMethod("NumbersOnly", function(value, element) {
return this.optional(element) || /^[0-9\-\+]+$/i.test(value);
}, "Phone must contain only numbers, + and -.");
$("#regForm").validate();
});
</script>
<script>
$(document).ready(function(){
$.validator.addMethod("username", function(value, element) {
return this.optional(element) || /^[a-z0-9\_]+$/i.test(value);
}, "Username must contain only letters, numbers, or underscore.");
$("#regForm").validate();
});
</script>
Revision: 51194
Updated Code
at September 16, 2011 16:42 by haidaica
Updated Code
<!--<div id="errorbox"><ul></ul></div>-->
$(document).ready(function(){
$("#commentForm").validate({
errorContainer: "#errorbox",
errorLabelContainer: "#errorbox ul",
wrapper: "li",
rules: {
name: "required",
email: {
required: true,
email: true,
},
comment: "required"
},
messages: {
comment: "This is a comment form. Why in the heck would you leave the comment blank?",
email: {
required: "Email address is required.",
email: "Email addresses are of the form user@host. Not yourRstupid."
},
name: {
required: "Stand up for your comments or go home."
}
}
});
});
//
$(document).ready(function(){
$("#commentForm").validate({
rules: {
name: {
required: true,
minlength: 2
},
email: {
required: "#csub:checked",
email: true,
},
comment: "required"
},
messages: {
comment: "This is a comment form. Why in the heck would you leave the comment blank?",
email: {
required: "Dude, you want the newsletter, but you didn't enter an email address?",
email: "Email addresses are of the form user@host. Not yourRstupid."
},
name: {
required: "Stand up for your comments or go home.",
minlength: jQuery.format("You need to use at least {0} characters for your name.")
}
}
});
});
//
$(document).ready(function(){
$.validator.addMethod("noanon", function(value) {
return value.toLowerCase().indexOf("anonymous") != 0;
}, 'Do not hide behind the cover of anonymity');
$("#commentForm").validate({
rules: {
name: {
required: true,
minlength: 2,
noanon: true
},
email: {
required: "#csub:checked",
email: true,
},
comment: "required"
},
messages: {
comment: "This is a comment form. Why in the heck would you leave the comment blank?",
email: {
required: "Dude, you want the newsletter, but you didn't enter an email address?",
email: "Email addresses are of the form user@host. Not yourRstupid."
},
name: {
required: "Stand up for your comments or go home.",
minlength: jQuery.format("You need to use at least {0} characters for your name.")
}
}
});
});
Revision: 51193
Updated Code
at September 16, 2011 16:41 by haidaica
Updated Code
$(document).ready(function(){
$("#commentForm").validate({
errorContainer: "#errorbox",
errorLabelContainer: "#errorbox ul",
wrapper: "li",
rules: {
name: "required",
email: {
required: true,
email: true,
},
comment: "required"
},
messages: {
comment: "This is a comment form. Why in the heck would you leave the comment blank?",
email: {
required: "Email address is required.",
email: "Email addresses are of the form user@host. Not yourRstupid."
},
name: {
required: "Stand up for your comments or go home."
}
}
});
});
//
$(document).ready(function(){
$("#commentForm").validate({
rules: {
name: {
required: true,
minlength: 2
},
email: {
required: "#csub:checked",
email: true,
},
comment: "required"
},
messages: {
comment: "This is a comment form. Why in the heck would you leave the comment blank?",
email: {
required: "Dude, you want the newsletter, but you didn't enter an email address?",
email: "Email addresses are of the form user@host. Not yourRstupid."
},
name: {
required: "Stand up for your comments or go home.",
minlength: jQuery.format("You need to use at least {0} characters for your name.")
}
}
});
});
//
$(document).ready(function(){
$.validator.addMethod("noanon", function(value) {
return value.toLowerCase().indexOf("anonymous") != 0;
}, 'Do not hide behind the cover of anonymity');
$("#commentForm").validate({
rules: {
name: {
required: true,
minlength: 2,
noanon: true
},
email: {
required: "#csub:checked",
email: true,
},
comment: "required"
},
messages: {
comment: "This is a comment form. Why in the heck would you leave the comment blank?",
email: {
required: "Dude, you want the newsletter, but you didn't enter an email address?",
email: "Email addresses are of the form user@host. Not yourRstupid."
},
name: {
required: "Stand up for your comments or go home.",
minlength: jQuery.format("You need to use at least {0} characters for your name.")
}
}
});
});
Revision: 51192
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 16, 2011 16:39 by haidaica
Initial Code
$(document).ready(function(){
$("#commentForm").validate({
errorContainer: "#errorbox",
errorLabelContainer: "#errorbox ul",
wrapper: "li",
rules: {
name: "required",
email: {
required: true,
email: true,
},
comment: "required"
},
messages: {
comment: "This is a comment form. Why in the heck would you leave the comment blank?",
email: {
required: "Email address is required.",
email: "Email addresses are of the form user@host. Not yourRstupid."
},
name: {
required: "Stand up for your comments or go home."
}
}
});
});
//
$(document).ready(function(){
$("#commentForm").validate({
rules: {
name: {
required: true,
minlength: 2
},
email: {
required: "#csub:checked",
email: true,
},
comment: "required"
},
messages: {
comment: "This is a comment form. Why in the heck would you leave the comment blank?",
email: {
required: "Dude, you want the newsletter, but you didn't enter an email address?",
email: "Email addresses are of the form user@host. Not yourRstupid."
},
name: {
required: "Stand up for your comments or go home.",
minlength: jQuery.format("You need to use at least {0} characters for your name.")
}
}
});
});
Initial URL
http://www.coldfusionjedi.com/index.cfm/2009/2/10/An-Introduction-to-jQuery-and-Form-Validation-2
Initial Description
Initial Title
Jquery validation plugin
Initial Tags
validation
Initial Language
jQuery