Wednesday, August 18, 2010

javascript validation for special charater/password

http://stackoverflow.com/questions/839483/need-to-handle-special-character-validation-using-javascript
function isSpclChar() {
var iChars = "!@#$%^&*()+=[]\\\';,./{}|\":<>?";
var val = document.getElementById('<%=txtdocNo.ClientID%>').value;
for (var i = 0; i < val.length; i++) {
if (iChars.indexOf(val.charAt(i)) != -1) {
{
alert("The box has special characters. \nThese are not allowed.\n");
document.getElementById('<%=txtdocNo.ClientID%>').value = '';
return false;
}


}
}
}


source from
http://www.dotnetspider.com/resources/28200-Special-character-Validation.aspx

function chkSpecialChars(input)
{
var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?"; for (var i = 0; i < input.length; i++)
{
if (iChars.indexOf(input.charAt(i)) != -1)
{
alert ("You are using special characters. \nThese are not allowed.\n Please remove them and try again.");
return false;
}
}
return true;
}


//password validation





Registration










Login:
Password:





source from
http://p2p.wrox.com/java-gui/3396-validation-special-character.html

No comments:

Post a Comment