【发布时间】:2017-07-23 01:58:20
【问题描述】:
请有人建议我,
在提交之前进行表单验证的最佳方法是什么?
实际情况就像,我有一个名为保存的按钮,所以当用户按下保存按钮时。
我需要验证数据并将流程传递给服务器以将数据存储在表中。
除了在服务器端进行表单数据验证之外,还有什么方法可以在客户端本身进行检查
<form>
<header>
<h1>Testing </h1>
</header>
<p>
Receipt number:
<input type="text" id="grn" class="tb1" onkeypress="return isNumber(event)" /> Type
<select name="evalu" id="evalu">
<option value="electrical">Electrical</option>
<option value="mechanical">Mechanical</option>
</select>
cad
<select name="cd" id="cd">
<option value="unit1">xv</option>
<option value="unit2">ed</option>
</select>
<input type="button" id="find" value="Find" class="button0" />
<br>
<br> Report No
<input type="text" name="irepno" id="irepno" class="tb1" maxlength="8" /> date
<input type="text" name="idt" id="idt" class="tb1" value="<%= new SimpleDateFormat(" dd-MM-yyyy ").format(new java.util.Date())%>">
<input type="button" id="search" value="Search" class="button0" />
<br></br>
<input type="button" value="Save the record" id="saverecord" class="button0">
</p>
</form>
【问题讨论】:
标签: javascript jquery servlets