私はウェブサイトで作業していて、フィールドが空にならないようにフォームをチェックする必要があります。空のフィールドがある場合は、フィールド名の右側にこのフィールドを空にする必要があります。
私のフォームコードは:-
<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;
}
}
アラート機能の代わりにスター(*)とメッセージを返す必要があります。フィールド名のすぐ右にあるこのフォームに入力してください。助けてください。よろしくお願いします。