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。你有沒有嘗試過基於jQuery的驗證庫? – Rup