I love this plugin (http://jqueryvalidation.org/) but I feel limited if I want to validate all fields remotely. I already have a php validation class and would like to use that.
Lets say I have fields like:
- fname
- lname
- username
and lets say I want to validate this entire form remotely...doing this seems redundant
$('#login form').validationOptions({
rules: {
"fname": {
remote: {
url: 'process.php',
type: 'post',
dataType: 'json',
dataFilter: function(data) {
var json = JSON.parse(data);
console.log(json);
if (json.result === true) {
return true;
}
return '"' + json.message + '"';
}
}
},
"lname": {
remote: {
url: 'process.php',
type: 'post',
dataType: 'json',
dataFilter: function(data) {
var json = JSON.parse(data);
if (json.result === true) {
return true;
}
return '"' + json.message + '"';
}
}
},
........etc......
},
});
Is there I can just tell the plugin to validate the entire form remotely without having to declare each field in the js or the remote rule and url each time...something like...
$('#login form').validationOptions({
remote: {
url: 'process.php',
type: 'post', //All form fields should be posted
dataType: 'json',
dataFilter: function(data) {
var json = JSON.parse(data);
console.log(json);
if (json.result === true) {
return true;
}
return '"' + json.message + '"';
}
},
});
I know the code will not work the way I wrote it but you should get my drift. And yes I know I could just do this using ajax post and use the success callback to do what I need it too but I'm using a template that has the plugin and works nicely would like to use what they already have the only change I want is to validate forms remotely in their entirety with out declaring each field and remote rule.