i am making a textfield in which the user will enter only alphanumeric password.i want to validate it through javascript but it is not validating.
<script>
function valid()
{
var flag;
var alphaExp=/^[0-9a-zA-Z]+$/;
if(!(myform.uname.value.match(alphaExp)))
{
alert("Username must contain Alphabet and Number Both");
myform.user.focus();
return false;
}
}
</script>
here myform is the name of form and uname is the name of textfield
can anyone tell me what could be the reason?
If I understand correctly, you want to make the use letters and numebrs in their password.
var alphaExp=/([a-z].*[0-9])|([0-9].*[a-z])/i;should work for that.