locked
How to disable button when user try send application again RRS feed

  • Question

  • User490317677 posted

    I'm working on project in MVC5 and I have page (Requestapplication.cshtml) , which User Submit form and than when they submitted, it will go to another page (ProcessRequest.cshtml),which take care of Process and also show a message to User for ex:.your application is received,until now no problem,but when user come back to same page again and they want to send application again ,i want some javascript or JQuery to disable button or show a message in button for ex:.you have been sent application, otherwise button is enabled for everyone if they have not tried before. 

    <form id="RMAForm" method="post" action="/Account/ProcessRequest">
    
    //some input field
    
    //Send Button
    <button id="btn" type="submit" class="btn btn-info btn-fill btn-wd">Send</button>
    
    
    </form>

    Can anyone point me into right direction ?! thanks

    Tuesday, March 13, 2018 11:13 AM

All replies

  • User-1838255255 posted

    Hi ManDown,

    According to your description and needs, please check the following sample code: 

      <button id="btn" type="submit" class="btn btn-info btn-fill btn-wd" onclick="this.disabled='true';return true;this.value='Submitting...'; this.form.submit();">Send</button>

    Best Regards,

    Eric Du 

    Wednesday, March 14, 2018 7:00 AM
  • User490317677 posted

    Hi Eric .

    I tried the code , but when i click on button,it cannot post the Data!! 

    Thursday, March 15, 2018 2:45 PM
  • User-1838255255 posted

    Hi ManDown,

    According to your needs, as far as i know, you could try use some jQuery plugin or jQuery Code to prevent double form submit, please check: 

    Simple double form submission prevention with jQuery: 

    https://thepugautomatic.com/2008/07/jquery-double-submission/ 

    Disabling the Submit Button to Prevent Double Form Submission: 

    http://biostall.com/disabling-submit-button-to-prevent-double-form-submission/ 

    Best Regards,

    Eric Du 

    Friday, March 16, 2018 1:56 AM
  • User-2054057000 posted

    You can store a value on the session variable which will identify whether the button has been previously clicked. If it is previously clicked then simply disable it on the view.

    Friday, March 16, 2018 9:14 AM
  • User490317677 posted
    Thanks Eric :) I will look at them.
    Friday, March 16, 2018 11:28 PM
  • User490317677 posted
    Hi yogyogi
    I thought about do something like you said but i just don’t. Know exactly:) Would you if it is possible, share some code or an example
    Thanks.
    Friday, March 16, 2018 11:36 PM
  • User2053451246 posted

    Always have the your form controller check your database to see if the processing has already been done.  If yes, do some if then stuff in your Razor view to disable the button.  I suggest instead to display a message or direct them to a different page from the controller before it even sends the form to the browser.

    Saturday, March 17, 2018 4:04 AM