简体   繁体   English

jQuery表单验证脚本问题

[英]Jquery Form Validation Script Issue

I am just learning Jquery, and I am having an issue with the validation function when I add it to a loading script. 我只是在学习Jquery,将验证函数添加到加载脚本时遇到了验证功能问题。 When I use the validation function separately from the loading script, it works without error. 当我将验证功能与加载脚本分开使用时,它可以正常工作。

This fiddle has both the loading and validation functinon separated, and the validation works http://jsfiddle.net/mikeef74/gzSDH/14/ 这个小提琴将加载和验证功能分开,验证工作为http://jsfiddle.net/mikeef74/gzSDH/14/

This is the loading script I am trying to make work with the validation in it: 这是我正在尝试在其中进行验证的加载脚本:

<script>
   var submit_hit = false;
   $(document).ready(function () {
      $('#iframe1').on('load', function () {
      $('#loader1').hide();

      if(submit_hit){
          $('#form_container').hide();
          $('#mydivhide1, #mydivhide2').show();
          $('body').css("background-image", "url(images/previewbg.jpg)");
      }
  });

  $('#form_710370').submit(function(e){
      $('#loader1').show();
          submit_hit = true;
          return true;
      });
});

</script> 

Try this. 尝试这个。 You don't nead document-ready event for these 2 other events. 您不需要为其他两个事件添加文档就绪事件。

var submit_hit = false;

$('#iframe1').on('load', function () {
   $('#loader1').hide();

   if (submit_hit) {
      $('#form_container').hide();
      $('#mydivhide1, #mydivhide2').show();
      $('body').css("background-image", "url(images/previewbg.jpg)");
   }
});

$('#form_710370').submit(function (e) {
   $('#loader1').show();
   submit_hit = true;
   return true;
});

$.validate();
$('#my-textarea').restrictLength($('#max-length-element'));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM