Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/431.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 尝试使用atomsphere的jquery插件对meteor表单进行表单验证_Javascript_Jquery_Forms_Validation_Meteor - Fatal编程技术网

Javascript 尝试使用atomsphere的jquery插件对meteor表单进行表单验证

Javascript 尝试使用atomsphere的jquery插件对meteor表单进行表单验证,javascript,jquery,forms,validation,meteor,Javascript,Jquery,Forms,Validation,Meteor,我想在meteor js中使用这个插件 现在当我使用console.log$('form').validate()时 我明白了 [form.mainForm,选择器:“form”,上下文:文档,jquery:“1.11.0”,构造函数:函数,toArray:function…] 我希望是真的还是假的,然后我可以在验证为真或假时提交表单 这是我的提交活动 Template.contactSubmit.events({ 'submit form': function(e) { e.pre

我想在meteor js中使用这个插件

现在当我使用console.log
$('form').validate()时

我明白了

[form.mainForm,选择器:“form”,上下文:文档,jquery:“1.11.0”,构造函数:函数,toArray:function…]

我希望是真的还是假的,然后我可以在验证为真或假时提交表单

这是我的提交活动

Template.contactSubmit.events({
  'submit form': function(e) {
    e.preventDefault();


    var post = {
      email: $(e.target).find('[name=email]').val(),
      name: $(e.target).find('[name=name]').val(),
      question: $(e.target).find('[name=question]').val(),
      found_us: $(e.target).find('[name=found_us]').val()

    };

  $('form').validate();

    post._id = Contacts.insert(post);
    Router.go('acorn', post);
  }
});
这是我的提交模板 注意第一次输入中所需的
数据

<template name="contactSubmit">
  <form class="mainForm">
    <div class="control-group">
        <label class="control-label" for="email">email</label>
        <div class="controls">
            <input data-required name="email" type="text" value="" placeholder="Your email"/>
        </div>
    </div>

    <div class="control-group">
        <label class="control-label" for="name">name</label>
        <div class="controls">
            <input name="name" type="text" value="" placeholder="name"/>
        </div>
    </div>

    <div class="control-group">
        <label class="control-label" for="question">question</label>
        <div class="controls">
            <textarea name="question" type="text" value="What do you want to build?"></textarea>
        </div>
    </div>

    <div class="control-group">
        <label class="control-label" for="found_us">found us</label>
        <div class="controls">
            <textarea name="found_us" type="text" value="How did you find us?"></textarea>
        </div>
    </div>

    <div class="control-group">
        <div class="controls">
            <input id="submitContact" type="submit" value="Submit" class="btn btn-primary"/>
        </div>
    </div>
  </form>
</template>

电子邮件
名称
问题
找到我们了

您没有像应该的那样使用插件。它需要这样一个有效的回调:

$('form').validate({
    sendForm: false,
    valid: function() {
        // Here is the code you want to run when the form is valid
        console.log("valid !");
    }
});

谢谢你。我一回到家就会选择答案并进行测试:)不客气,很高兴它有帮助,我在家测试了它,它成功了。如果你被困在那里,我就在那里。