views:

27

answers:

0

hi all,

i have come up with a semi-solution to this issue, but wondering if there might be a better way. i am currently running the query validator plugin on a group of inputs and all works fine normally. my issue is i am doing an additional check via an ajax post on one of the inputs to make sure the username is unique before submiting. when that check back comes back as positive, the jquery validator doesn't clear the validation messaging until the next keypress. due to this there are conflicting messages 'yes this is a unique name', and 'username is invalid'. what i need is a simple way to clear the validation rules on the fly for one element. to get this to work, i fire a custom event after my ajax post comes back with valid input. then in the keypress method of the validator i listen for that event and then remove the error class and error html from the surrounding input. is this the best way? seems hack-tastic to me.

here is the code i use to clear the error messaging when i know the entered input is valid:

 onkeyup: function (element) {

        $('body').bind('checkUserValidation', function (e) {
            $(element).parent().removeClass('error');
            $(element).parent().find('p.error').html('');
        });


    },