JavaScript not Validating
JavaScript not Validating
此代码有什么问题?
网页正在导入此外部JavaScript,但是,如果用户输入错误,则不会显示警告消息框。
page.jsp:
<form name="reg-form" action="ServletName"
onsubmit="return validateForm()" method="POST">
<table>
<tr>
<td>
<input name="organization" type="text" required>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Register">
</td>
</tr>
</table>
</form>
val.js:
function validateForm()
{
var result=true;
var message="";
var orgnization=document.forms["reg-form"]["organization"].value;
if(orgnization.length<3)
{
message+="'nName of Organization cannot be less than 3 characters long";
result=false;
}
if(!result)
{
alert(message);
}
return result;
}
试试这个:
function validateForm()
{
var result=true;
var message="";
var orgnization=document.getElementsByName["organization"][0].value;
if(orgnization.length<3)
{
message +="'n Name of Organization cannot be less than 3 characters long";
result=false;
}
if(!result)
{
alert(message);
}
return result;
}
相关文章:
- jQuery is not loaded
- AngularJS JSON not arriving php
- $rootScope not working
- reactRedux is not defined
- jQuery document.ready not working
- Javascript/Jquery Blob not showing Chrome PDF
- ReferenceError: not defined
- ReferenceError: cordova is not defined @ng-cordova.min.js:7
- Javascript getElementsByTagName not working?
- jQuery's trim()的前缀为not运算符
- Javascript - element.childNodes does not see an append.newch
- SemanticUI模态not onDeny/onApprove事件未激发
- WebkitTransform not fluent
- JQuery.val( ) not working
- Tomcat websocket is not working
- :not选择器不适用于ul类-备选方案
- Javascript JSON.parse not working
- javascript captcha not validating
- JavaScript not Validating
- jQuery.validationEngine v2.6.1 Not Validating?