prototype1.5应用--简单的表单提交验证
JAVASCRIPT ::function aaa(){
if($F('name')==""){
new Element.update("div1","<div>没有输入姓名</div>");
new Field.focus("name");
return false;
}else new Element.update("div1","");
if($F('pass')==""){
new Element.update("div2","<div>没有输入密码</div>");
new Field.focus("pass");
return false;
}else new Element.update("div2","");
new Form.disable('mf');
}HTML ::<script language="javascript" src="prototype.js"></script>
<form id="mf">
<input type="text" id="name"><div id="div1"></div>
<input id="pass" type="password"><div id="div2"></div>
<input type="button" onclick="javascript:aaa();" value="提交">
<input type="button" onclick="javascript:new Form.reset('mf');" value="重置">
</form