php で javascript を使用して電子メールとパスワードを検証しようとしています。しかし、それは私にエラーを示しています:-
{"error": "Shell form does not validate{'html_initial_name': u'initial-js_lib', 'form': <mooshell.forms.ShellForm object at 0xa50990c>, 'html_name': 'js_lib', 'label': u'Js lib', 'field': <django.forms.models.ModelChoiceField object at 0xa69d64c>, 'help_text': '', 'name': 'js_lib'}"}
私のphpコードは
<form id="formLogin" name="formLogin" method="post" action=" " onsubmit="return validateForm()/">
<div class="divLogin">
<table>
<tr>
<td> Enter your Email: </td>
<td> <input type="text" name="txtEmail" required="required" autocomplete="off" /> </td>
</tr>
<tr>
<td> Enter your Password: </td>
<td> <input type="password" name="pwd" minlength="6" required="required" autocomplete="off" /> </td>
</tr>
</table>
</div>
<div>
<input type="submit" class="btnLogin" value="Go" style="display:inline-block; margin-left:350px; font-weight:bold; font-size:12px;" />
</div>
</form>
私のJSコードは
function validateForm(){
var checkemail=document.forms["formLogin"]["txtEmail"].value;
var atpos=checkemail.indexOf("@");
var dotpos=checkemail.lastIndexOf(".");
var checkpwd=document.forms["formLogin"]["pwd"].value;
if (checkemail==null){
document.getElementById("checkemail").innerHTML = "Please Enter Email Address";
return false;
}
if (checkpwd==null)
{
document.getElementById("checkpwd").innerHTML = "Please Enter Password";
return false;
}
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=checkemail.length)
{
alert("Not a valid e-mail address");
return false;
}
if (checkpwd==null || checkpwd=="")
{
alert("Password must be filled out");
return false;
}
}