jQuery验证:如果表单有效,则显示“提交"按钮 [英] jquery validate: IF form valid then show submit button

查看:86
本文介绍了jQuery验证:如果表单有效,则显示“提交"按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基本的空白表格,只想显示一次提交按钮:

I have a basic empty form and would like to only show the submit button once:

  1. 数据已输入到表单中.
  2. 所有必填/有效字段均正确.

在表格正确后,在提交"按钮上消失之前.

Before fading in the submit button once the form is correct.

快速jsfiddle: http://jsfiddle.net/36JZL/

Quick jsfiddle: http://jsfiddle.net/36JZL/

<form action="#" method="post">
    <label>Name</label>
    <input type="text" name="name" class="required" value="" />

    <label>Email</label>
    <input type="email" name="email" class="required email" value="" />

    <label>Message</label>
    <textarea name="message" class="required"></textarea>

    <input type="submit" name="save" value="Save" class="hide" />
</form>

$('form').validate();

推荐答案

根据艾伦·布坎南(Alan Buchanan)的回答,这可能有用:

Following on from Alan Buchanan's answer, this might work:

$('#yourform input,#yourform textarea').bind('oninput', function(){

    if ($('#yourform').valid()) $('#submitButton').fadeIn();

});

-注释和参考.

这篇关于jQuery验证:如果表单有效,则显示“提交"按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆