GoldPearl
Programmer
- Aug 9, 2005
- 64
hello ppl,
can anybody tells me wat is wrong with the following code because it is skipping the last condition ("Your user ID is of the wrong format....)
function uname()
{
var iChars = "!@#$%^&*()+=-[]\\\';,/{}|\":<>?";
var iChars1 = "/^\w+\.\w+$/";
if (frmusermaint.txtuserid.value.length == 0)
{
alert('Please enter your user ID');
frmusermaint.txtuserid.focus();
return false;
}
else
{
for (var i = 0; i < frmusermaint.txtuserid.value.length; i++)
{
if (iChars.indexOf(frmusermaint.txtuserid.value.charAt(i)) != -1)
{
alert ("Your user ID has special characters.\n These are not allowed.\n Please remove them and try again.\n ");
frmusermaint.txtuserid.select();
return false;
}
}
}
if (((frmusermaint.txtuserid.value.length < 6) || (frmusermaint.txtuserid.value.length > 25)) && (frmusermaint.txtuserid.value.length)!= 0)
{
alert("The user ID must be between 6-25 characters long.\n");
frmusermaint.txtuserid.select();
return false;
}
else
{
for (var j = 0; j < frmusermaint.txtuserid.value.length; j++)
{
if (iChars1.indexOf(frmusermaint.txtuserid.value.charAt(j)) != -1)
{
alert ("Your user ID is of the wrong format.\n Required format is like 'jane.keen'. Please try again.\n ");
frmusermaint.txtuserid.select();
return false;
}
}
}
}
Cheers,
Gold Pearl
can anybody tells me wat is wrong with the following code because it is skipping the last condition ("Your user ID is of the wrong format....)
function uname()
{
var iChars = "!@#$%^&*()+=-[]\\\';,/{}|\":<>?";
var iChars1 = "/^\w+\.\w+$/";
if (frmusermaint.txtuserid.value.length == 0)
{
alert('Please enter your user ID');
frmusermaint.txtuserid.focus();
return false;
}
else
{
for (var i = 0; i < frmusermaint.txtuserid.value.length; i++)
{
if (iChars.indexOf(frmusermaint.txtuserid.value.charAt(i)) != -1)
{
alert ("Your user ID has special characters.\n These are not allowed.\n Please remove them and try again.\n ");
frmusermaint.txtuserid.select();
return false;
}
}
}
if (((frmusermaint.txtuserid.value.length < 6) || (frmusermaint.txtuserid.value.length > 25)) && (frmusermaint.txtuserid.value.length)!= 0)
{
alert("The user ID must be between 6-25 characters long.\n");
frmusermaint.txtuserid.select();
return false;
}
else
{
for (var j = 0; j < frmusermaint.txtuserid.value.length; j++)
{
if (iChars1.indexOf(frmusermaint.txtuserid.value.charAt(j)) != -1)
{
alert ("Your user ID is of the wrong format.\n Required format is like 'jane.keen'. Please try again.\n ");
frmusermaint.txtuserid.select();
return false;
}
}
}
}
Cheers,
Gold Pearl