Link to home
Start Free TrialLog in
Avatar of MickeC
MickeCFlag for Sweden

asked on

Numbers and A to Z in form

One little thing, why is this wrong if i also want a field for a-z, A-Z and 0-9.

if (/^[a-zA-Z0-9]*$/.test(document.mcform.frmParticipantPassword.value)) {

alert("Only number is allowed for quantity!");
document.mcform.frmParticipantPassword.focus();
return false;

it don't seems to work
<script language="JavaScript" type="text/javascript">
<!--
function MCValidation()
{


if (document.mcform.frmParticipantPassword.value == "") {

alert("Password is required!");
document.mcform.frmParticipantPassword.focus();
return false;

}

if (document.mcform.frmParticipantPassword.value.length < 6) {

alert("Password must contain at least six characters!");
document.mcform.frmParticipantPassword.focus();
return false;

}
if (/^[a-zA-Z0-9]*$/.test(document.mcform.frmParticipantPassword.value)) {

alert("Only number and a-z is allowed!");
document.mcform.frmParticipantPassword.focus();
return false;

} 

return true;

}

// -->
</script>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial