Greetings.
This is a snippet I found that forces new members to use an alphanumeric password. Actually, this script works exactly as it should, except… It insists on calling my cgi script “EVEN” if the wrong value in entered. In other words, instead of halting the process, it displays the alert message, but when you click “OK”, it calls the script anyway. This sort of defeats the purpose.
I know very little about Java scripting, other than how to cut and paste whatever I can find. Something simple here is missing. Would anyone know what that is? Have a look:
<script language="Javascript">
function chkFormat(){
var bad=0;
var req='';
if ((document.myform.password_1.value.length < 6)||(document.myform.password_1.value.length >10)){
req = req + 'Password must be 6-10 characters\n';
bad=1;}
var re_alphanum = /^[a-zA-Z0-9]{6,10}$/;
if (!re_alphanum.exec(document.myform.password_1.value)){
req = req + 'Invalid Password format, non-alphanumeric characters: '+ document.myform.password_1.value+'\n';
bad=1;}
var re_alpha = /[a-zA-Z]/;
if (!re_alpha.exec(document.myform.password_1.value)){
req = req + 'Invalid Password format, One alphanumeric character is required: '+ document.myform.password_1.value+'\n';
bad=1;}
var re_num = /[0-9]/;
if (!re_num.exec(document.myform.password_1.value)){
req = req + 'Invalid Password format, One numeric character is required: '+ document.myform.password_1.value+'\n';
bad=1;}
if (bad){
alert('The Following Problems were Encountered:\n'+req);
return false;
}else{
alert('Good Password');
return true;
}
}
</script>
<body bgcolor="#FFFFFF" text="#000000">
<form name="myform" method="post" action="http://mydomain.com/cgi-bin/script.cgi" java script:void(0);" onsubmit="chkFormat();">
<input type="text" name="password_1">
<input type="submit" name="Submit" value="Submit">
</form>
Would really appriciate any help,
Dave H