0
jspの英数字のパスワード検証用の関数をjavascriptで作成し、その関数をテキストボックスのonkeypressイベントで呼び出しても動作しません。javascriptの英数字パスワードのバリデーション
function alphanumeric(inputtxt) {
var mypswd = document.getElementById(inputtxt).value;
mypswd = mypswd.trim();
if (mypswd == "" || mypswd == null) {
alert("Please enter password");
} else if (!mypswd.match((/^(?=.\d)(?=.[a-z])(?=.*[A-Z])[0-9a-zA-Z]{8,}$/)) {
alert(" password must be alphanumeric");
}
}
<form name="form1" method="post" action="Register">Username :
<br>
<input type="text" name="uname" onkeypress="return checkSpcialChar(event)" onkeydown=" alphanumeric(inputtxt)" />
<br/>Password :
<br>
<input type="password" name="pwd" onkeypress="return checkSpcialChar(event)" />
<br/>
<br>
<input type="submit" name="action" value="Submit" onsubmit="check()" />
<input type="submit" value="Back" />
</form>
助けてください。
、いくつかの説明を追加します。それ以外の場合は、コードのただ一片のです... – Dekel