• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Form Validation Question

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a form in my Training Database Application (Informix SQL, JSP) that allows the user to enter training records for officers in my department. Some training courses are allowed to have subtitles. For example �Swat Training� is a training course title but the type of Swat Training might be �Tactical Handgun�, a sub-course title. The Training Course title is entered in a drop down box, as well as the sub course title. If a training course is not allowed to have sub course titles (Done with SQL Table � Field Variable) the sub course title drop down is disabled (Done with variable in JSP). If the training course title is allowed sub course titles, than the sub course title drop down is enabled (Done with variable in JSP). The problem I am having is that when I go to validate the form, I get an error when the sub course title drop down is disabled, the form can�t focus from the validation script which is written in javascript. Hence question � Is there a way to determine whether or not a form object is disabled using javascipt?
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, this can be done. "disabled" is an attribute of the input element; it can be set to true or false, and its value can compared against those two. The syntax would be something like
if (document.form.inputElement.disabled == 'true')
The apostrophs around the boolean value may not be becessary, I don't quite remember.
 
Sheriff
Posts: 67682
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved to the HTML/Javascript forum.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ulf already answered the question, but just to follow up on the quotation marks, I just tried it, and putting quotes doesn't work (tested in IE and Firefox). Since disabled is a boolean, you can just do the following:

if (document.yourForm.yourSelect.disabled)
 
I would challenge you to a battle of wits, but I see you are unarmed - shakespear. Unarmed tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic