var submitbutton = $('#form_submit');
submitbutton.addClass('disabled');
$('#form_primer').on('keyup', validator(this));
$('#form_szek').on('keyup', validator(this));
function validator(event){
if(isNaN(event.value)){
$(event).css('border-color', 'red');
submitbutton.addClass('disabled');
}
else{
$(event).css('border-color', 'green');
submitbutton.removeClass('disabled');
}
};
So, I have this javascript, and don't want to write the validator function twice. This script should disable the submit button and color the border red or green based on the input. How can I pass the form element to the function? Also, how can I disable the form submission properly? The button can't be pressed, but if the user hits enter with text inside, it will still submit it.