Monday, February 7, 2011

Validation to Check for special Character

Below javascript code function returns false for entered special character
and true for non special character.




function CheckForSpecialCharacter( controlValue ) 
     {
        var regex = /^[a-zA-Z0-9\s]+$/;
        if( !controlValue.match( regex ) ) 
        {
            alert('Special Character is not allowed due potential security threat.');
            return false;
        }

No comments:

Post a Comment