Hello Everyone,

Can you please give me some advise on how to validate input or select based on the class used?

For example: <input id="name" type="text" class="alphanumeric" value="">

Then for the validation:

if input class = "alphanumeric"
if !isAlphaNumeric(input.value)
alert(Enter valid value);input.focus

Before, I used onblur on the input to call the validator but it keeps prompting when I tried to out focus the input and I need to refresh the page.

Looking forward to your replies.

Thanks in advance

I would actually use a custom attribute (the convention is data-attributename for custom attributes). For example:

<input type="text" id="txtPassword" data-validationtype="password" />

You can then quite easily use jQuery to setup the events for validating.

    $('input[data-validationtype="password"').bind('onblur', function(){
        //code to validate passwords

    $('input[data-validationtype="numeric"').bind('onblur', function(){
        //code to if the value entered is numeric

//more types of validation