这可能是一个非常基本的问题,但我真的可以使用一些帮助。我正在使用来自 javascript-coder[dot]com 的插件,并且似乎无法弄清楚如何让脚本在验证时忽略我的默认值。这是代码
<form id="signupform" name="signupform" action="">
<fieldset>
<label>
<input type="text" name="FirstName" onBlur="if(this.value==''){this.value='Name:'}" onFocus="if(this.value=='Name:'){this.value=''}" value="Name:" />
</label>
<label>
<input type="text" name="Email" onBlur="if(this.value==''){this.value='Email:'}" onFocus="if(this.value=='Email:'){this.value=''}" value="Email:"/>
</label>
<label>
<input type="text" name="Mobile Phone" />
</label>
<div class="buttons-wrapper"><a href="javascript: submitform()" class="button">Submit Info Now!</a></div>
</fieldset>
</form>
<script language="JavaScript" type="text/javascript"
xml:space="preserve">//<![CDATA[
//You should create the validator only after the definition of the HTML form
var frmvalidator = new Validator("signupform");
frmvalidator.EnableMsgsTogether();
frmvalidator.addValidation("FirstName","req","Please enter your First Name");
frmvalidator.addValidation("FirstName","maxlen=20", "Max length for FirstName is 20");
frmvalidator.addValidation("Email","maxlen=50");
frmvalidator.addValidation("Email","req");
frmvalidator.addValidation("Email","email");
frmvalidator.addValidation("Mobile Phone","req");
frmvalidator.addValidation("Mobile Phone","maxlen=50");
frmvalidator.addValidation("Mobile Phone","numeric", "Please enter a valid number");
//]]></script>
<script type="text/javascript">
function submitform()
{
if(document.signupform.onsubmit())
{//this check triggers the validations
document.signupform.submit();
}
}
</script
请让我知道,如果你有任何问题