Hi, I have the following running which works fine: if (form.password.value == "") { alert( "Please enter a password" ); form.password.focus(); return false ; } if (form.password.length < 6) { alert( "Password must be greater than 6 characters" ); form.password.focus(); form.password.value = ""; return false ; } Code (markup): I want to add into this a check to see if the user has entered at least one number. I have tried various things which have not worked. Can anyone please advise. Cheers, Adam
try something like this if (document.forms["formname"]["password"].value.length < "6") { alert( "Password must be greater than 6 characters" ); return false; }
There are many solutions, this would be one of them: if (form.password.value.search(/[0-9]+/) == -1) { alert("bla bla"); form.password.focus(); return false; } Code (markup):