我做了一定数额的确认,但不能阻止提交。 请帮助我验证其他遗留领域。 这是我的法典:
<form action="" method="post" id="contacts-form" onsubmit="return >
<fieldset>
<div class="field">
<input type="text" value="Name:" id="name" onfocus="if(this.value== Name: ){this.value= }" onblur="if(this.value== ){this.value= Name: }" />`enter code here`
</div>
<div class="field">
<input type="text" value="E-mail:" id="email" onfocus="if(this.value== E-mail: ){this.value= }" onblur="if(this.value== ){this.value= E-mail: }" />
</div>
<div>
<textarea cols="1" rows="1" id="message" onfocus="if(this.value== Message: ){this.value= }" onblur="if(this.value== ){this.value= Message: }">Message:</textarea>
</div>
<div class="link"><a href="#" onclick="document.getElementById( contacts-form ).reset()">Clear</a> <a href="#" onclick="document.getElementById( contacts-form ).submit(validateForm();)">Send</a></div>
www.un.org/Depts/DGACM/index_spanish.htm The Js Code I used is this:
function validateForm()
{
var x=document.forms["contacts-form"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
}