I have a jqGrid form for creating new users and what i want is to ensure that (among the other fields submitted by the form) the username does not already exist in the database.
So i created a beforeSubmit action, that is executed when the submit button is pressed but before the form is submitted.
I think the function works, because the code bellow always returns "User exists";
beforeSubmit:function(postdata,formid) { return[false,"User exist"]; }
But when i try ti use the $.get to make an ajax request to the server in order to see if the username already exists, i always get a k is undefined
error. This is the code the produces the error
beforeSubmit:function(postdata,formid) {
$.get("project-management?r=Users/usernameExists&tmpl=json&username=" + postdata.username, function(data) {
return[false,"Exists"];
}); }
I know that this is not a real validation but shouldn't produce the same result as the first script?
Thanks a lot