I keep getting an undefined for the val that gets passed and not sure why when there’s something being put for the form field.
$('#addNewUserForm input[name="username"]').rules('add', {
remote: {
type: 'post',
url: 'addnewuser/is_username_available',
data: {
'username': function() { return $('#username').val(); }
},
dataType: 'json'
}
});
Since you’re using
[name="username"]in your selector, I’ll assume that input does not have an ID = “username”, which is what you’re referencing with$('#username'). Without an ID, should be able to reference the current selector using$(this):