grey out submit button until form filled out

后端 未结 3 748
萌比男神i
萌比男神i 2021-02-09 02:23

I have the following form:

 
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-09 03:30

    The script would go in the of your document. Like so.

    
    

    One way would be to match the values of the inputs and then remove the grayed out class from your button if the values aren't still the same as the default. Here is a demo.

    HTML

    
    
    

    CSS

    .disabled {opacity:.2;}
    

    jQuery

    if ($('.text-input').val() == "some text" ) {
        $('.submit').addClass('disabled');    
    }
    

    http://jsfiddle.net/APGmy/11/

提交回复
热议问题