简体   繁体   English

在parsley.js中提交之前发生的事件

[英]event before submit in parsley.js

I have some form and script for parsley: 我有一些香菜的形式和脚本:

<form id="myForm">
   <div id="overlay"></div>
   <input id='name' type='text' placeholder='enter name..'>
   <button type='submit'>Submit</button>
</form>

<script>
    var myForm = $('#myForm');
    myForm.parsley();
</script>

Sometimes on my page another scripts add class 'active' to #overlay. 有时,在我的页面上,另一个脚本会将类“活动”添加到#overlay中。 This class depends on whether you need to validate the input. 此类取决于您是否需要验证输入。 So, I need for some requirement, when I click on submit and before validating. 因此,当我单击提交并进行验证之前,我需要一些要求。 For example smth like this: 例如这样的:

$('button').click(function(){
  if($('#overlay').hasClass('active))
    {$('#name').parsley()}
})

If #overlay has class 'active', then you need to validate input.. Help me ) 如果#overlay具有“活动”类,则您需要验证输入。(帮助我)

It's probably not as easy as it should. 这可能不那么容易。

If you are using a lightbox of some kind, ideally you would set disable on all your inputs, and set add "[disable]" to the excluded option. 如果您正在使用某种形式的灯箱,最好你会设置disable所有的输入,并设置添加"[disable]"excluded选项。

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

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