validate plugin prevent to check an existing user in edit mode
I got an user signup form with jquery validate running.
This works flawless.
Now the thing is:
I want edit the user, so the form is populated with excisting data.
when I dont alter anything jquery.validate will find an excisitng user and place an error.
I want to keep the validation functionality because when i want to change the username it has to check if theres an excisting username and give an eror, excepts for the current populated username field.
how do i achieve that? this is my original function for adding users
- $("#useredit").validate({
errorElement: "em",
debug:false,
rules: {
firstname: "required",
surname: "required",
username: {
required: true,
minlength: 4,
remote: baseurl+"admin/user_manager/username_check_edit",
},
group_id: {
required: true,
min: 1
},
password: "required",
password2: {
equalTo: "#password"
}
},
messages: {
username: {
required: "Dit is een verplicht veld.",
minlength: jQuery.format("Gebruik minimaal {0} tekens."),
remote: jQuery.format("Deze gebruikersnaam is al in gebruik.")
}
}
});
I tried something like this, but i dont know the proper way, any ideas?
- $(function() {
$("#username").blur(function()
{
if ($(this).val() !=this.defaultValue)
{
alert(required:true);
}else{
alert(required:false);
}
});
but when i put this in the validate function it wont work