我在一个网站上工作,我必须检查一些表格,这样任何字段都不应该为空,如果有任何空字段,它应该写这个字段在字段名称的右侧是空的
我的表单代码是:-
<form action="Owners Infoback.php" onsubmit="return validateForm()" method="post" name="enquiry" id="" class="form-body-02">
<ul>
<li>1. Name of owner <input name="Name_of_owner" type="text" class="textarea-bk-02" id="" value="" style="border:none; width:330px; margin-left:40px; margin-top:15px; height:20px;"/>
</li>
<li>
2. Name of company:<br />
<p>(Enter name registered)</p></label>
<input name="Name_of_company_registered" type="text" class="textarea-bk-02" id="" value="" style="border:none; width:330px; margin-left:40px; margin-top:13px; height:20px;"/>
</li>
<li>
3. Address:<p>(Write your own manufacturer address)</p>
<input name="Owner_address" type="text" class="textarea-bk-02" id="" value="" style="border:none; width:330px; height:20px; margin-left:40px; margin-top:13px;"/></li>
</li>
<li>
4. Email id:
<input name="Owner_Email_id" type="text" class="textarea-bk-02" id="" value="<?php echo "{$row[3]}";?>" style="border:none; width:330px; margin-left:40px; margin-top:13px; height:20px;"/>
</li>
<li><input name="Save" type="submit" class="send-btns-02 right" value="save" style="margin-top:5px;" >
<div class="clear"></div>
</li>
</ul>
我的java脚本函数是:-
function validateForm(string msz)
{
var x=document.forms["enquiry"]["Name_of_owner"].value;
if (x==null || x=="")
{
msz="First name must be filled out");
return msz;
}
x=document.forms["enquiry"]["Name_of_company_registered"].value;
if (x==null || x=="")
{
alert("Name of company registered filled out");
return false;
}
x=document.forms["enquiry"]["Owner_address"].value;
if (x==null || x=="")
{
alert("Owner addressmust be filled out");
return false;
}
x=document.forms["enquiry"]["Owner_Email_id"].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;
}
}
我想要而不是警报功能,它应该返回一个星号(*)和消息请填写此表格,就在字段名称的右边,请帮助我..提前谢谢..