Reputation: 25996
I would like to validate each form element with different rules.
E.g.
Can that be done with JQuery, when I would like to do that in my ajax file?
$(document).ready(function(){
$("form#create_form").submit(function() {
var title = $('#title').attr('value');
var owner = $('#owner').attr('value');
// check values
var is_okay = 0;
if (title == '') {
alert('Title is required');
} else if (owner == '') {
alert('Owner is required');
} else {
is_okay = 1;
}
...
Upvotes: 0
Views: 99
Reputation: 9382
I wouldn't reinvent the wheel and instead use either:
http://validity.thatscaptaintoyou.com/Demos/index.htm
or
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
Upvotes: 2