PROBLEM WITH DISABLING SUBMIT BUTTON TILL ALL INPUTS FILLED |
PROBLEM WITH DISABLING SUBMIT BUTTON TILL ALL INPUTS FILLED |
shankar from vizag |
May 28 2019, 09:12 AM
Post
#1
|
Advanced Member Group: Members Posts: 202 Joined: 18-June 13 Member No.: 19,316 |
Greetings,
I have a form with input fields. I would like to disable submit button till all input fields of the form entered. I placed the code below and it is not working. <head> <script> $(document).ready(function (){ validate(); $('#notenum, #note_date).change(validate); }); function validate(){ if ($('#notenum').val().length > 0 && $('#note_date').val().length > 0) { $("input[type=submit1]").prop("disabled", false); } else { $("input[type=submit1]").prop("disabled", true); } } </script> </head> <center><table class = "table table-striped table-bordered table-hover table-condensed" > <tr class="active"><td align="right">Note Number:</td><td><input type = "text" readonly name="notenum"> </td></tr> <tr><td align="right">Date:</td><td><input type="text" id="myDatepicker" name="note_date" placeholder="Click to pick date" ></td></tr> </table></center> <input class ="btn btn-primary" type="submit" id="submit1" name="submit1" value="SAVE" onsubmit='this.disabled = true;'>i Request to guide me to fix the problem. Thanks in advance. |
CharlesEF |
May 29 2019, 05:55 PM
Post
#2
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
Your scripts are using jQuery but you haven't linked to the jQuery library. Once you do that it will work.
|
shankar from vizag |
May 29 2019, 07:57 PM
Post
#3
|
Advanced Member Group: Members Posts: 202 Joined: 18-June 13 Member No.: 19,316 |
|
Lo-Fi Version | Time is now: 19th April 2024 - 05:38 AM |