javascript - Test if field is disabled/readonly

Hi !

can i check via javascript,  if the formtext field is readonly or not ?
for example i have a form input like this:

HTP.tabledata (HTF.formtext ('F_CERT_PERIOD',  50, 50,
                                      common.coderef (datarow.cert_period,
                                                      'CERTIFICATION_PERIOD',
                                                      userrow.orgid
                                      ),
                                      cattributes => 'class="blueInput" onFocus="this.blur; alert("This field is read-only");" '
                        ),
                        cattributes => 'colspan=2'
         );
         HTP.tablerowclose;



thx for help
Zee75Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

halfbloodprinceCommented:
Try This:
this will give you the value "diabled " if the textbox is readonly
document.getElementById("TextBox1").disabled
0
Zee75Author Commented:
halfbloodprince:
how do I identify the id element in formtext?

HTP.tabledata (HTF.formtext ('F_CERT_PERIOD',  50, 50,
                                      common.coderef (datarow.cert_period,
                                                      'CERTIFICATION_PERIOD',
                                                      userrow.orgid
                                      ),
                                      cattributes => 'class="blueInput" onFocus="this.blur; alert("This field is read-only");" '
                        ),
                        cattributes => 'colspan=2'
         );
0
Zee75Author Commented:
Getting javascript error stating object is expected.  any suggestions
0
gazdzidCommented:
Does this help
<script type="text/javascript"> 
function other() { 
var form = document.form; 
if (form.plan[4].selected) { 
form.otherfeedback.disabled = false; 
form.otherfeedback.focus(); 
} else { 
form.otherfeedback.value = ""; 
form.otherfeedback.disabled = true; 
} 
} 
function valid() { 
var form = document.form; 
var what = form.plan.value; 
if (what == "" || what == "none") { 
alert("No option selected!"); 
return false; 
} 
if (form.plan[4].selected) { 
if (form.otherfeedback.value == "") { 
alert("No feedback entered!"); 
return false; 
} 
} 
return true; 
} 
</script> 
</head>
<body>
<form action="feedback.cfm" method="post" id="form" name="form" onsubmit="return valid();">
<select name="plan" onchange="other()"> 
<option value="none">
Select Your Answer -- 
<option>
Potatos 
</option>
<option value="More bulletins">
Onions 
</option>
<option value="Don't know">
Carrots 
</option>
<option value="Other">
Other (please specify) 
</option>
</select> 
<p>
<textarea name="otherfeedback" id="otherfeedback" wrap="PHYSICAL" rows="3" cols="40" disabled></textarea> 
</p>
<input type="submit" value="Submit"> 
</form>
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.