I need to create a simple validation function basically mirroring the default jQuery validation. So far it's working but I can't duplicate making the error message disappear as you type. It does disappear once you click out of the input field but I want it to trigger as I type. Please can you point me to the correct function, I'm using .change at the moment.
Jsfiddle - http://jsfiddle.net/clintongreen/tLpB4/7/
JS
$('#save_menu').click(function(){
var value = $('input#new_menu').val();
if (value.length){
console.log('shows success message');
$('.success').css('display','block');
}
else{
console.log('shows error message');
$('.error').css('display','block');
}
});
$('#new_menu').on('change', function() {
$('.error').hide();
console.log('hides error message');
});
HTML
<input id="new_menu" type="text" name="new_menu" placeholder="Please enter your menu title" onkeypress="return event.keyCode!=13">
<input name="save_menu" value="Save Menu" type="submit" id="save_menu">
<label class="error" style="display: none;">Please enter a Menu name</label>
<label class="success" style="display: none;">That is correct</label>