0
連絡先ページにHTMLフォームフィールドがあり、それがデータをPHPページに送信します。xhtml連絡フォームフィールドは必須ですか?
ユーザーが値を入力しない場合は、フォームフィールドを必須にして、ラベルの横に赤色(*)を表示したいと考えています。
どうすればいいですか?
<form id="contact_form" method="post" action="contact.php">
<p style="margin-top:20px">
<label for="title">Title</label><br/>
<input id="your_name" name="your_name" type="text" style="width:94%"/>
</p>
<p style="margin-top:20px">
<label for="initial">Initial</label><br/>
<input id="initial" name="initial" type="text" style="width:94%"/>
</p>
<p style="margin-top:20px">
<label for="surname">Surname</label><br/>
<input id="surname" name="surname" type="text" style="width:94%"/>
</p>
<p style="margin-top:20px">
<label for="tel_number">Tel number</label><br/>
<input id="tel_number" name="tel_number" type="text" style="width:94%"/>
</p>
<p style="margin-top:20px">
<label for="email">Email</label><br/>
<input id="email" name="email" type="text" style="width:94%"/>
</p>
<p style="margin-top:20px">
<label for="enquiry">Enquiry</label><br/>
<textarea id="enquiry" name="enquiry" rows="7" cols="10" style="width:94%"></textarea>
</p>
<p style="margin-top:50px">
<input type="submit" value="Send Message"/><br/>
</p>
</form>
。 jQueryベースの検証ライブラリを試しましたか? – Rup