php獲取數(shù)據(jù)庫結果集方法(推薦)
673
2024-01-11
1、驗證方法 validationNumber(e, num) e代表標簽對象,num代表保留小數(shù)位數(shù)
function validationNumber(e, num) { var regu = /^[0-9]+.?[0-9]*$/; if (e.value != "") { if (!regu.test(e.value)) { alert("請輸入正確的數(shù)字"); e.value = e.value.substring(0, e.value.length - 1); e.focus(); } else { if (num == 0) { if (e.value.indexOf('.') > -1) { e.value = e.value.substring(0, e.value.length - 1); e.focus(); } } if (e.value.indexOf('.') > -1) { if (e.value.split('.')[1].length > num) { e.value = e.value.substring(0, e.value.length - 1); e.focus(); } } } } }
2、驗證整數(shù)
<asp:TextBox ID="txtNg" name="txtNg" runat="server" Height="16px" Width="98px" Font-Size="9pt" CssClass="EditTextBox" onpropertychange="validationNumber(this,0)"></asp:TextBox>
3、保留一位小數(shù)
<asp:TextBox ID="txtChglinecost" name="txtChglinecost" runat="server" Height="16px" Width="98px" Font-Size="9pt" CssClass="EditTextBox" onpropertychange="validationNumber(this,1)"></asp:TextBox>
4、保留兩位小數(shù)
<asp:TextBox ID="txtStdyr" name="txtStdyr" runat="server" Height="16px" Width="98px" Font-Size="9pt" CssClass="EditTextBox" onpropertychange="validationNumber(this,2)"></asp:TextBox>
5、保留三位小數(shù)
只需要把 validationNumber(this,3) 方法中的第二個參數(shù)改為3即可。
保留四位小數(shù)、保留五位小數(shù),以此類推...
以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,同時也希望多多支持綠夏網(wǎng)!
#免責聲明#
本站[綠夏技術導航]提供的一切軟件、教程和內(nèi)容信息僅限用于學習和研究目的;不得將上述內(nèi)容用于商業(yè)或者非法用途,否則,一切后果請用戶自負。本站信息來自網(wǎng)絡收集整理,版權爭議與本站無關。您必須在下載后的24個小時之內(nèi),從您的電腦或手機中徹底刪除上述內(nèi)容。如果您喜歡該程序或內(nèi)容,請支持正版,購買注冊,得到更好的正版服務。我們非常重視版權問題,如有侵權請郵件[admin@lxwl520.com]與我們聯(lián)系進行刪除處理。敬請諒解!