asp.net數(shù)據(jù)驗(yàn)證控件
1、非空數(shù)據(jù)驗(yàn)證控件RequiredFiledValidator。
屬性:ControlToValiata 指驗(yàn)證控件對(duì)哪一個(gè)控件進(jìn)行驗(yàn)證。例如驗(yàn)證TextBox控件的ID屬性txtPwd,只要將RequiredFiledValidator??丶腃ontrolToValidata屬性設(shè)置為txtPwd。代碼:this.RequiredFiledValidator1.ControlToValidata="txtPwd";
ErrorMessage屬性:用于指定頁(yè)面中使用RequiredFiledValidator控件時(shí)顯示的錯(cuò)誤消息文本。代碼:this.RequeiredFiledValidator1.ErrorMessage=“*”;
2、數(shù)據(jù)比較驗(yàn)證控件
CompareValidator:
重要屬性:ControlToCompare 指定要對(duì)其進(jìn)行值比較的控件ID。例如驗(yàn)證兩次ID。
this.compareValidator1.ControlToCompare="txtPwd";
this.compareValidator1.ControlToValidate=""txtRepwd:
Operator屬性:進(jìn)行驗(yàn)證時(shí)進(jìn)行的操作。例如驗(yàn)證輸入密碼和再次輸入密碼是否一致。
this.CompareValidator1.OPerator=ValidationCompareOperator.Equal;
Type屬性:指定要進(jìn)行比較的兩個(gè)值的數(shù)據(jù)類(lèi)型;例如驗(yàn)證兩者的數(shù)據(jù)類(lèi)型
this.。。Type=ValidationDataType.String;
ValueToCompare屬性:指定要比較的值。
<title>數(shù)據(jù)驗(yàn)證技術(shù)</title> </head> <body> <form id="form1" runat="server"> <div> <h2>數(shù)據(jù)驗(yàn)證技術(shù)</h2> <h3>非空數(shù)據(jù)驗(yàn)證</h3> <div > <asp:Label ID="lab" Text="用戶(hù)信息" runat ="server" ></asp:Label ><br /><br /> <asp:Label ID="Name" Text ="姓名:" runat ="server" ></asp:Label> <asp:TextBox ID="txtName" runat="server" ></asp:TextBox> <asp:RequiredFieldValidator ID="RedFile" runat ="server" ControlToValidate ="txtName" SetFocusOnError ="true" ErrorMessage ="姓名不能為空" ></asp:RequiredFieldValidator><br /><br /><br /> <asp:Button ID="btOK" runat="server" Text="驗(yàn)證" OnClick="btOK_Click" style="height: 21px" /> </div> </div> <div> <hr /> <h3>數(shù)據(jù)比較控件驗(yàn)證</h3> <var> <asp:Label ID="LabTxt" runat="server" Text="用戶(hù)信息" BorderStyle ="NotSet"></asp:Label><br /> </var> <asp:Label ID="lab2" runat="server" Text="姓名:"></asp:Label> <asp:TextBox ID="lab3" runat ="server" ></asp:TextBox> <asp:RequiredFieldValidator ID="RequFlie2" runat="server" ErrorMessage ="姓名不能為空" SetFocusOnError ="true" ControlToValidate ="txtName"></asp:RequiredFieldValidator><br /><br /> <asp:Label ID ="lab4" runat="server" Text ="密碼:" ></asp:Label> <asp:TextBox ID="txtPwd" runat ="server" TextMode="Password" ></asp:TextBox><br /><br /> <asp:Label ID ="lab5" runat="server" Text ="確認(rèn)密碼:"></asp:Label> <asp:TextBox ID="txtRepwd" runat ="server" TextMode ="Password" ></asp:TextBox> <asp:CompareValidator ID="Comval" runat ="server" ControlToValidate ="txtRepwd" ControlToCompare ="txtPwd" ErrorMessage="確認(rèn)密碼與原密碼不匹配"></asp:CompareValidator><br /><br /> <asp:Button ID="btnCheck" runat ="server" Text ="驗(yàn)證2" OnClick="btnCheck_Click" /> </div> </form>
3、數(shù)據(jù)類(lèi)型驗(yàn)證控件
CompareValidator對(duì)照特定的數(shù)據(jù)類(lèi)型驗(yàn)證用戶(hù)的輸入,以確保用戶(hù)輸入的是數(shù)字還是日期等。
例:用到的控件屬性,CotrolToValidator、operator、type屬性。驗(yàn)證用戶(hù)輸入的出生日期與類(lèi)型是否匹配。
關(guān)于JQuery的淡入淡出效果的演示。。
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>jquery動(dòng)態(tài)</title> <script src=""> </script> <script type="text/javascript" > $(function(){ $(".nav li").hover(function(){ $("ul",this ).fadeIn(); }, function(){ $("ul") }) $) </script> <meta charset="utf-8" /> <style type="text/css" > body{ font-family :Arial ,sans-serif; font-size:15px; } .nav{ margin:0; padding:0; list-style:none ; } .nav li { float :left ; width:150px; position :relative ; } .nav li a{ background:#262626; color:#fff; display :block ; padding :8px 7px 8px 7px; text-decoration:none ; text-align :center ; text-transform :uppercase ;//小寫(xiě)變大寫(xiě) } .nav li a:hover { color:#bf3826; } .nav ul{ position :absolute ; left:0px; display:none ; margin: 0 0 0 -1px; padding :0; list-style:none ; border-bottom :3px solid #bf3826; } .nav ul li{ width:180px; float :left ; border-top :none ; } .nav ul a{ display :block ; height :15px; padding: 8px 7px 8px 7px; color :#fff; text-decoration :none ; border-top:none ; border-bottom:1px dashed #bf3826; } </style> </head> <body> <div style="width :650px ; margin:0 auto"> <ul class=" nav"> <li><a href=" #">Home</a></li> <li> <a href="#">ipnoe</a> </li> </ul </div> </body> </html>
相關(guān)文章
ASP.NET Core中使用MialKit實(shí)現(xiàn)郵件發(fā)送功能
這篇文章主要介紹了ASP.NET Core中使用MialKit實(shí)現(xiàn)郵件發(fā)送功能,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-10-10如何利用FluentMigrator實(shí)現(xiàn)數(shù)據(jù)庫(kù)遷移
這篇文章主要給大家介紹了關(guān)于如何利用FluentMigrator實(shí)現(xiàn)數(shù)據(jù)庫(kù)遷移的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04在Framework4.0中實(shí)現(xiàn)延遲加載的實(shí)現(xiàn)方法
延遲加載,亦稱(chēng)延遲實(shí)例化,延遲初始化等,主要表達(dá)的思想是,把對(duì)象的創(chuàng)建將會(huì)延遲到使用時(shí)創(chuàng)建,而不是在對(duì)象實(shí)例化時(shí)創(chuàng)建對(duì)象,即用時(shí)才加載。2011-08-08Entity Framework Core批處理SQL語(yǔ)句
這篇文章介紹了Entity Framework Core批處理SQL語(yǔ)句的方法,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-02-02.Net Core實(shí)現(xiàn)選擇數(shù)據(jù)熱更新讓服務(wù)感知配置的變化
這篇文章主要介紹了.Net Core實(shí)現(xiàn)選擇數(shù)據(jù)熱更新讓服務(wù)感知配置的變化,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-03-03解決.NET?Core企業(yè)微信openapi回調(diào)地址請(qǐng)求不通過(guò)的問(wèn)題
這篇文章介紹了解決.NET?Core企業(yè)微信openapi回調(diào)地址請(qǐng)求不通過(guò)的問(wèn)題,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-06-06WPF實(shí)現(xiàn)定時(shí)刷新UI界面功能
這篇文章主要為大家詳細(xì)介紹了WPF實(shí)現(xiàn)定時(shí)刷新UI界面功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07理解HttpHandler,并為所有*.jpg圖片生成一段文字于圖片上
HttpHandler就是最終相應(yīng)HTTP請(qǐng)求,生成HTTP響應(yīng)的處理器,他們的實(shí)例由asp.net運(yùn)行時(shí)創(chuàng)建,,并生存在asp.net的運(yùn)行時(shí)環(huán)境中,如果asp.net運(yùn)行時(shí)是處理請(qǐng)求的工廠(chǎng),HttpHandler是處理請(qǐng)求的工人2012-03-03