您好,登錄后才能下訂單哦!
- <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
- <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
- YzTest
- </asp:Content>
- <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
- <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
- <script type="text/javascript">
- $(document).ready(function () {
- $("#Form1").submit(function () {
- var a = $("#Email").val();
- var validate = true;
- alert(a);
- if (a == "") {
- validate = false;
- $("#DEmail").html("對不起,該選項不能為空");
- }
- else {
- var reg =/^(0|[1-9]\d*)$/;
- alert(reg.test(a));
- if (reg.test(a)) {
- if (a > 100 || a < 0) {
- alert("a");
- validate = false;
- $("#DEmail").html("年齡范圍在0-100之間!");
- }
- else {
- $("#DEmail").html("");
- }
- }
- else {
- $("#DEmail").html("請輸入數字");
- validate = false;
- }
- }
- return validate;
- });
- });
- </script>
- <h3>驗證測試</h3>
- <%using (Html.BeginForm("YzTest", "Home", FormMethod.Post, new { id = "Form1" }))
- {%>
- <table>
- <tr>
- <td>
- (Email驗證)
- </td>
- <td><input type="text" id="Email"/><div id="DEmail"></div></td>
- </tr>
- <tr><td><input type="submit" value="驗證" /></td></tr>
- </table>
- <%} %>
- </asp:Content>
貼代碼。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。