Ver código fonte

答题时日期时间校验问题

keyuan 4 anos atrás
pai
commit
d8338a8d17

+ 1 - 4
src/main/webapp/WEB-INF/page/content/diaowen-design/answer-survey-m.jsp

@@ -196,15 +196,12 @@
 									 		<span class="quTitleNum">${i.count }、</span>
 											<span class="quTitleText">${en.quTitle}</span>
 									 	</label>
-
-										 <%--<input id="qu_${en.quType }_${en.id }" type="text" name="qu_${en.quType }_${en.id }" class="fillblankInput" >--%>
-
 										 <c:choose>
 											 <c:when test="${en.checkType eq 'DATE'}">
 												 <input type="text" name="qu_${en.quType }_${en.id }" class="inputSytle_1 fillblankInput" readonly style="margin-top: 10px;" placeholder="请选择日期时间" >
 											 </c:when>
 											 <c:when test="${en.answerInputRow > 1 }">
-												 <textarea name="qu_${en.quType }_${en.id }" rows="${en.answerInputRow }" class="inputSytle_2 fillblankInput" style="margin-top: 10px;"  > ></textarea>
+												 <textarea name="qu_${en.quType }_${en.id }" rows="${en.answerInputRow }" class="inputSytle_2 fillblankInput" style="margin-top: 10px;"  > </textarea>
 											 </c:when>
 											 <c:otherwise>
 												 <input type="text" name="qu_${en.quType }_${en.id }" class="inputSytle_1 fillblankInput" style="margin-top: 10px;"  placeholder="请输入${(en.checkType eq null || en.checkType eq 'NO') ? '内容':en.checkType.name},为${en.isRequired eq  0?'选填':'必填'}"  >

+ 6 - 5
src/main/webapp/js/common/ans-common.js

@@ -28,6 +28,7 @@ function bindDateEvent(){
             }
         }
        // console.debug("dateType:"+dateType);
+       //  validateCheck($(this).parents(".li_surveyQuItemBody"),true);
        laydate.render({
             elem: surveyQuItemBody.find("input.fillblankInput")[0] //指定元素
             ,type: 'datetime'
@@ -98,20 +99,20 @@ function checkoutData(checkType, value) {
     } else if (checkType == "DATE") {
 
         //日期的正则表达式
-        /*var reg1 = /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/;//2014-01-01
+        var reg1 = /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/;//2014-01-01
                      var regExp1 = new RegExp(reg1);
                      var reg2 = /^(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d$/;//12:00:00
                      var regExp2 = new RegExp(reg2);
                      var reg3 = /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s+(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d$/;//2014-01-01 12:00:00
                      var regExp3 = new RegExp(reg3);
-                     if(!(regExp1.test(value) || regExp3.test(value))){
+                     if(!(regExp1.test(value) || regExp2.test(value) || regExp3.test(value) )){
                      //						alert("日期格式不正确,正确格式为:2014-01-01");
                      errorType = "DATE";
                      validateStatus = false;
-                     }*/
-        if (/Invalid|NaN/.test(new Date(value).toString())) {
+                     }
+        /*if (/Invalid|NaN/.test(new Date(value).toString())) {
             validateStatus = false;
-        }
+        }*/
 
 
     } else if (checkType == "IDENTCODE") {

+ 3 - 1
src/main/webapp/js/common/ans-m.js

@@ -344,7 +344,9 @@ $(document).ready(function(){
     //填空题
     $(".fillblankInput,.dwMFillblankInput,.dwChenMFillblankInput").blur(function(){
         lgcommon($(this));
-        validateCheck($(this).parents(".li_surveyQuItemBody"),true);
+        if(checkType!="DATE"){
+            validateCheck($(this).parents(".li_surveyQuItemBody"),true);
+        }
     });
 
     function resetQuNum(){

+ 5 - 3
src/main/webapp/js/common/ans-p.js

@@ -234,7 +234,6 @@ $(document).ready(function(){
         return result;
     }
 
-
     function validateCheck(quItemBody,isSubForm){
         if(quItemBody.is(":visible")){
 
@@ -349,7 +348,7 @@ $(document).ready(function(){
                     errorHtml="<div class=\"errorItem\"><label for=\"\" class=\"error\">请输入电话或手机,为必答项!</label></div>";
                 }else if(checkType == "DATE"){
                     //2014-01-01 12:00:00
-                    errorHtml="<div class=\"errorItem\"><label for=\"\" class=\"error\">请输入如:2014-01-01,为必答项!</label></div>";
+                    errorHtml="<div class=\"errorItem\"><label for=\"\" class=\"error\">请输入日期或时间,为必答项!</label></div>";
                 }else if(checkType == "IDENTCODE"){
                     errorHtml="<div class=\"errorItem\"><label for=\"\" class=\"error\">请输入身份证号,为必答项!</label></div>";
                 }else if(checkType == "ZIPCODE"){
@@ -433,7 +432,10 @@ $(document).ready(function(){
     $(".fillblankInput,.dwMFillblankInput").blur(function(){
         lgcommon($(this));
         answerProgressbar($(this));
-        validateCheck($(this).parents(".li_surveyQuItemBody"),true);
+        var checkType = $(this).parents(".li_surveyQuItemBody").find(".checkType").val();
+        if(checkType!="DATE"){
+            validateCheck($(this).parents(".li_surveyQuItemBody"),true);
+        }
     });