45
rated 0 times
[
49]
[
4]
/ answers: 1 / hits: 37936
/ 10 Years ago, wed, october 15, 2014, 12:00:00
I am making a form and making input field to read only using JavaScript. I want to change the default color for read only attribute to green or yellow.
HTML
<input type=radio name=sex value=male>Male<br/>
<input type=radio name=sex value=female>Female <br/>
Age:<input type=text name=age id=age size=20>
Hobbies:<input type=text name=hobbies id=hobbies size=20><br/>
Phone:<input type=text name=phone id=phone size=20><br/>
When someone click on female the input having Id's age and phone becomes reading only using JavaScript.
JS
$(function() {
$(input[name='sex']).change(function() {
if($(this).val() == female) {
$(#age).attr(disabled, true);
style=backgroundcolor=green
$(#phone).attr(disabled, true);
} else if($(this).val() == male) {
$(#age).attr(disabled, false);
$(#phone).attr(disabled, false);
}
});
});
I want to change the color of input field when it is read only.
More From » jquery