Monday, July 7, 2008

Allows Symbols JS

//This Allows Symbols only
/*The argument strText is the id of the textbox. This allows only symbols without text or numbers.*/
function symbolOnly(strText)
{
var str = strText.value;
//var format = /[^a-zA-Z0-9]+$/;
var format = /^[^0-9a-zA-Z]+$/;
if(str == "" str == null str == '')
{
alert("Enter any symbols");
strText.focus();
strText.select();
return false;
}
else
{
if(str.match(format))
{
return true;
}
else
{
alert("Enter Only Symbols");
strText.select();
strText.focus();
return false;
}
}
}

No comments: