I have the following code, see below:
$(document).ready(function(){
var prefixNumber = $('.numeric').val();
if(prefixNumber.match(????){
prefixNumber.addClass('.field-error');
}
});
What I’m looking to happen is when the user types something in the input.numeric field and it doesnt match one of these numbers, say…1, 3, 8 or 999 a class .field-error is added to the input field which has a red background colour. Kind of trying to make a live error notification if that makes sense.
Any help would be greatly appreciated, Thanks
Use a change handler on your input: