Hi,
i did the code for validating the string it working fine but i need to modify that code using regular expression. if u know plz modify and reply me
1.
isNotSpecialChar(string)
It is a validate function to check the given string is not a Special Char.Here we can also given a additional parameter.These parameter value treated as not a special char.
for example
pm1 = ‘
manditory value ;
pm2 = ‘_’ //– (Exceptional Value) this is
optional value;
pm3 = ‘@’ //– (Exceptional Value) this is
optional value;
pm4 = ‘.’ //– (Exceptional Value) this is
optional value;
.
.
.
isNotSpecialChar(pm1,pm2,pm3,pm4,….)
isNotExceptionalChar(string)
It is a validate function to check the string is not a Normal Char and not a Number and not a Special char
for example
isNotExceptionalChar(‘`ds9A§’) //Output : return false
<script language=”JavaScript”>
function isNotSpecialChar(string)
{
var ichars = “~!@#$%^&*()_+|`-=\[]{};’:”,./<>?”;
if(arguments.length>1)
for(var i = 1;i < arguments.length;i++)
{
ichars = ichars.replace(arguments[i],”);
}
for (var i = 0; i < string.length; i++) {
if (ichars.indexOf(string.charAt(i)) != -1)
return false;
}
return true;
}
function isNotExceptionalChar(string)
{
var ichars = “~!@#$%^&*()_+|
for (var i = 0; i < string.length; i++)
{
if (ichars.indexOf(string.charAt(i)) == -1)
return false;
}
return true;
}
isNotExceptionalChar(‘`ds9A§’) //return false
isNotSpecialChar(‘
</script>
By
T.Varghese