Jquery prop disabled value is not seen on server

679 views Asked by At

I am setting and disabling the textbox using jquery. When I click on save and posted to server, I can't see this particular element value.

$('#FirstName').prop('disabled', true);

How can I disable the textbox and post the value to server?

2

There are 2 answers

2
PeterKA On

By design disabled form controls are not included in the submitted data. If your aim is to prevent users from changing the set value use readonly instead:

$('#FirstName').prop('readOnly', true);

To make all form fields within a given div, use the following:

$('div :input').prop( 'readOnly', true );
0
Shubh On

You could possibly use something what Trevor suggested here

$('.container').find('input, textarea, button, select').attr('disabled','disabled');

Fiddle works fine with Chrome/Mozilla/IE 10,9,8