1

I have several issues to discuss with you:

  1. I need all elements in the form disabled after a server answer "400" from ajax. So the user knows that he just submit that form (ajax).
  2. I'm also thinking of setting a status to "readonly" after a submit is clicked as well.

The reasons behind these issues is: I have a booking form which a user can choose multiple rooms for a group. So each room must have it's own guest. Saying I want to make a booking of 3 rooms for my friends. So I select the check-in and check-out. Number of rooms (3). And put in my friends' detail to each form. After I submit the first room. The data has uploaded and all the fields are disabled. Then I do the same to next room by clicking a tab. As pictured below:

Booking Form

Further requirements:

  1. Do you have some example of jQuery disable form elements after submit?
  2. Is there a better way of booking multiple rooms in the same time than this?
halfer
  • 19,824
  • 17
  • 99
  • 186
Wilf
  • 2,297
  • 5
  • 38
  • 82
  • 1
    Have you tried: `$('form').on('submit', function() { $(this).find(':input').attr('disabled', 'disabled'); });` ? – Ketan Modi May 09 '13 at 05:48
  • @Ronak Not yet but will do. Thank you :) But I rather need it disabled after ajax answer "400" then disable the elements. – Wilf May 09 '13 at 05:49
  • Try looking this link [http://stackoverflow.com/questions/5290525/disable-all-form-elements-inside-div][1] – Yethroy Jerome Sep 18 '14 at 14:14

2 Answers2

4

When you receive the status 400 from ajax call, call the below statement.

 $('#formID input[type=text]').attr("disabled",true);

This will disable all the input text boxes that are under the 'formId'.

Alpesh Prajapati
  • 1,593
  • 2
  • 18
  • 38
2

U can disable all input text areas using below one.

jQuery 1.5 and below

$("input[type=text]").attr('disabled', true);

jQuery 1.6+

$("input[type=text]").prop('disabled', true);

Kasun Gamage
  • 346
  • 2
  • 3
  • 18