我正在使用jQuery AJAX和ASP.Net網絡方法。我需要檢查輸入到HTML控件的用戶數據,我知道有很多jQuery插件,但我一一使用它們,但沒有運氣,問題是他們使用<form id="" action=""></form>
標籤,而我沒有。另外我不提交我的表單,因爲它是一個jQuery AJAX應用程序。我想要一些字段只有浮點,而有些字段不爲空。誰能幫忙?用戶數據驗證
這裏是我的代碼:
<table width="100%">
<tr>
<td><asp:Label ID="lblcontry" runat="server" Text="Select Country"> </asp:Label></td>
<td>
<select id="cmbCountry">
<option value="0">Select Country</option>
</select>
</td>
</tr>
<tr>
<td><asp:Label ID="lblCname" runat="server" Text="City Name"></asp:Label></td>
<td><input type="text" id="txtCityName" /></td>
</tr>
<tr>
<td><asp:Label ID="lblDialCode" runat="server" Text="Dial Code"></asp:Label></td>
<td><input type="text" id="txtDialCode" /></td>
</tr>
<tr>
<td><asp:Label ID="lblKeywords" runat="server" Text="KeyWords"></asp:Label></td>
<td><textarea id="txtKeywords" cols="20" rows="2"></textarea></td>
</tr>
<tr>
<td></td>
<td>
<input type="button" id="btnsave" value="Save" />
<input type="button" id="btnCancel" value="Cancel" />
</td>
</tr>
</table>
$(document).ready(function() {
$("#btnsave").click(function() {
//here i want to check fields first and then save data.
SaveData();
});
}
我有進口的所有文件和CSS。
'parseFloat'檢查將不會完全工作。如果該值是例如'0hi',則parseFloat將反彈'0'而不是'NaN'。 – kubetz 2011-12-19 13:43:16
就像我說過的,這是一個如何做手動驗證,更改您的需求的例子。 – 2011-12-19 13:46:30