jquery validate: IF form valid then show submit button

后端 未结 3 2028
离开以前
离开以前 2020-12-17 04:51

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

  1. Data has been entered into the form.
  2. All required/va
相关标签:
3条回答
  • 2020-12-17 05:02

    Suggest that you fire some javascript on the change events of your form inputs and check whether each one passes your validation. If it does then fade in the button.

    0 讨论(0)
  • 2020-12-17 05:20

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

    $('#yourform input,#yourform textarea').bind('oninput', function(){
    
        if ($('#yourform').valid()) $('#submitButton').fadeIn();
    
    });
    

    - Notes and reference.

    0 讨论(0)
  • 2020-12-17 05:23

    There is no function in jQuery to do this. You need to bind an event to the submit of this form or to each of the fields and validate the required fields text length and if all are greater 0. then you can submit the form or fade in the submit button.

    The submnit event will be triggered when you hit an enter inside the form in any one of the fields.

    Take a look at this link.

    http://api.jquery.com/submit/

    0 讨论(0)
提交回复
热议问题