验证
 1 function AddPersonClick() {
 2             if (Check() == true) {
 3                 sum = sum + 1;
 4                 $("[id$='hid_sum'").val(sum);
 5                 //alert(sum);
 6                 var logint = $('input:radio[name="radsex"]:checked').val();
 7                 $("[id$='hidsex']").val(logint);
 8 
 9                 var personname = $("[id$='PersonName']").val();
10                 var sex = $("[id$='hidsex']").val();
11                 var id = $("[id$='Identity']").val();
12                 var brithday = $("[id$='BirthDay']").val();
13                 var phone = $("[id$='PhoneNum']").val();
14                 if (personname == "" || sex == "" || id == "" || brithday == "" || phone == "") {
15                     layer.msg('请将人员信息填写完整');
16                     return false;
17                 }
18                 else {
19                     var Info = personname + ";" + sex + ";" + id + ";" + brithday + ";" + phone;
20                     $("[id$='hid_person']").val(Info);
21                     //alert($("[id$='hid_person']").val());
22                     var obj = $("#tbodyPerson");
23                     var list_hid = $("[id$='hid_person']").val().split(';');
24                     if (list_hid[1] == "0")
25                         list_hid[1] = "";
26                     else
27                         list_hid[1] = "";
28                     var tr = $("<tr id='addPerson" + sum + "' value='" + sum + "'></tr>");
29                     var td = $("<td class='person_td'><input id='addname' style='height:26px; width:100px;' type='text' value='" + list_hid[0] + "'/></td><td class='person_td'><input id='addsex' style='height:26px;  width:100px;' type='text' value='" + list_hid[1] + "'/></td><td class='person_td'><input id='addidentity' style='height:26px;  width:200px;' type='text' value='" + list_hid[2] + "'/></td><td class='person_td'><input id='addbrithday' style='height:26px;  width:150px;' type='text' value='" + list_hid[3] + "'/></td><td class='person_td'><input id='addphone' style='height:26px;  width:150px;' type='text' value='" + list_hid[4] + "'/></td> <td class='person_td'><a href='#' onclick='Del(this)'><img src='../images/Del_MouseOut.png' /></a></td>");
30                     tr.append(td);
31                     obj.append(tr);
32                 }
33             }
34             else
35                 return false;
36         }
37 
38 function Check() {
39             var regID = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X|x)$/;//18位数身份证验证正则表达式 x不区分大小写
40             var regPhone = /^[1][358]\d{9}$/;//手机号码正则表达式            
41             var IDNum = $("[id$='Identity']").val();
42             var PhoneNum = $("[id$='PhoneNum']").val();
43             if ((!regPhone.test(PhoneNum)) && (regID.test(IDNum))) {//手机号码错误,身份证对
44                 layer.msg("手机号码错误");
45                 return false;
46             }
47             if ((!regID.test(IDNum)) && (regPhone.test(PhoneNum))) {//身份证错误,手机号码对
48                 layer.msg("身份证错误");
49                 return false;
50             }
51             if ((!regID.test(IDNum)) && (!regPhone.test(PhoneNum))) {//手机和身份证都错
52                 layer.msg("身份证错误,手机号码错误");
53                 return false;
54             }
55             else
56                 return true;
57         }
View Code


自己写一个日期时间控件

要引用样式和JS

<link href="../laydate/need/laydate.css" rel="stylesheet" />

<script src="../laydate/laydate.js"></script>

 

<input type="text" class="form-control" id="BirthDay" runat="server" required="required" onclick="laydate()">

laydate({
            elem: '#BirthDay',
            event: 'focus'
        });