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?
 
gazdzidConnect With a Mentor Commented:
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
 
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(&#34;This field is read-only&#34;);" '
                        ),
                        cattributes => 'colspan=2'
         );
0
 
Zee75Author Commented:
Getting javascript error stating object is expected.  any suggestions
0
All Courses

From novice to tech pro — start learning today.