Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
6
rated 0 times [  12] [ 6]  / answers: 1 / hits: 73587  / 11 Years ago, thu, july 4, 2013, 12:00:00

I'm having a problem re-enabling an input after it has been disabled on the page load.



I'm using two inputs to accept two dates, but I want it that the second input is not enabled until the first one has a value.



<div id=date1 data-role=fieldcontain>
<label for=date1-start id=date1-startlbl>Start Date</label>
<input name=date1-start id=date1-start type=date data-role=dateboxdata-options='{mode: calbox, overrideDateFormat: %Y-%m-%d, beforeToday: true}' data-theme=a onchange=showdate()/>
<label for=date1-end id=date1-endlbl>End Date</label>
<input name=date1-end id=date1-end type=date data-role=datebox data-options='{mode: calbox, overrideDateFormat: %Y-%m-%d, beforeToday: true}' data-theme=a onchange=datechart()/>
</div>


The second input is disabled successfully on the page load with.



$(#date1-end).prop(disabled, true);


The first date has an onchange event that calls the following function



function showdate(){
if ($(#date1-start).val() != null){
if ($(#date1-end).val() != ){
datechart();
}
else{
$(#date1-end).prop(disabled, false);
$(#date1-end).trigger('change');
}
}
}


The function is called and prop(disabled, false) when reached fires without any errors, but the input remains disabled. The trigger('change') I am using is an attempt at refreshing the element but the same problem exists without it.



I have tried different variations of .attr from an older version of Jquery but I also get the same problem.



I am using Jquery 1.9.1, Jquery-mobile 1.3.1 and PhoneGap 2.7.0


More From » jquery

 Answers
21

Working example: http://jsfiddle.net/d9vzs/



This is not how you enable disable jQUery Mobile input elements.



It can be done with this functions:



$( input ).textinput( disable );


$( input ).textinput( enable );


Official documentation: http://api.jquerymobile.com/textinput/#method-disable


[#77199] Wednesday, July 3, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
soniap

Total Points: 626
Total Questions: 119
Total Answers: 110

Location: Palestine
Member since Tue, Jul 20, 2021
3 Years ago
;