Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Required Fields IF....

Status
Not open for further replies.

suprcr250

Programmer
Joined
Aug 13, 2002
Messages
4
Location
US
How do you set up Input fields where a group of fields are required once one of them has been checked(or filled out).
What I have is a form with about 6 fields. A few of them are required but I also have a few credit card fields that I don't want to be required all the time. I only want the fields pertaining to the credit card info (like #, expiration,etc.) to be required if they choose credit card as the payment type. Any help would be appreciated.
 
Why don't you use divs to show/hide information?

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
suprcr250,

change the "disabled" property of the optional fields.
[tt]
var df = document.forms[0];

if (/* condition stating optional fields should be enabled */) {
bDisabled = false;
}
else bDisabled = true;

df.optField1.disabled = bDisabled;
df.optField2.disabled = bDisabled;
df.optField3.disabled = bDisabled;
[/tt]

=========================================================
if (!succeed) try();
-jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top