-2

This is my HTML snippet :

<form  method="post" id="form-post">{% csrf_token %}
  <div class="form-group">
    <label for="form-labname">Lab Name</label><br>
    {{form.labname}}
  </div>
  <div class="form-group">
    <label for="form-cidr">CIDR Block</label><br>
    {{form.cidr}}
  </div>
  <div class="form-group">
    <label for="form-budget">Budget</label><br>
    {{form.budget}}
  </div>
 <input id='submit' type='submit' class="btn btn-primary"  
  style="background-color:#3facdb;border-color=#3facdb;" value='Submit' />
</form>
  </div>
<input type="hidden" id="myemail" name="variable" value="{{ emailid }}">
</input>

I need the submit button to be disabled after the form values have been submitted. I tried many cases but even though the button gets disabled, the form is not submitted. I also need to submit the hidden "myemail" value.

This is my javascript :

 $(document).ready(function () {
 $("#form-post").submit(function () {
    $("#submit").attr("disabled", true);
    return true;
   });
});

Although this disables the submit button, the values are not submitted.

Siddharth Singh
  • 105
  • 3
  • 15

1 Answers1

-1

Create a Boolean variable and make it true on button click. Also add [disable]=variable_name to your button HTML declaration.

Denver Gomes
  • 44
  • 1
  • 12