Javascriptはユーザー登録の検証を実現する.
10617 ワード
JS
function isRight(){
//
var username=document.getElementById("username").value;
if(username==""||username==null){
alert(" !!");
return false;
}
//
var password=document.getElementById("password").value;
if(password==""||password==null){
alert(" !!");
return false;
}
var password2=document.getElementById("password2").value;
if(password2==""||password2==null){
alert(" ");
return false;
}
//
if(password!=password2){
alert(" !!");
return false;
}
//
var email=document.getElementById("email").value;
if(!/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(email)){
alert(" ");
return false;
}
}
HTML<form action="#" method="get" onsubmit="return isRight()">
<table border="0px" cellpadding="5px" cellspacing="0xp">
<th colspan="2">
th>
<tr>
<td>
<span>
:
span>
td>
<td>
<input id="username" type="text" name="username"/>
td>
tr>
<tr>
<td>
<span >
:
span>
td>
<td>
<input id="password" type="password" name="password"/>
td>
tr>
<tr>
<td>
<span>
:
span>
td>
<td>
<input id="password2" type="password" name="password2"/>
td>
tr>
<tr>
<td>
<span>
:
span>
td>
<td>
<input id="email" type="text" name="emial"/>
td>
tr>
<tr>
<td>
<span>
:
span>
td>
<td>
<input id="epassword" type="password" name="epassword"/>
td>
tr>
<tr>
<td colspan="2" style="text-align: center;">
<input type="submit" value=" "/>
td>
tr>
table>
form>