cshanek
Junior Member
Posts: 4
Registered: 8/31/2005
Location: San Antonio
Member Is Offline
|
| posted on 8/31/2005 at 07:41 PM |
|
|
Element Dependency
Greetings,
As always I am impressed with your work. One thing I was thinking about however were cases which require a form object to possess some sort of
property depending on the value of another form object.
For instance, I have several cases where I would like to have "if (this.dropdown.options[this.dropdown.selectedIndex].text == 'myparam'
&& !this.dependentfield.value) then output generic alert.
I looked at your m key for ideas, but since I am inept at javascript I failed miserably.
I appreciate your help,
|
|
|
cshanek
Junior Member
Posts: 4
Registered: 8/31/2005
Location: San Antonio
Member Is Offline
|
| posted on 8/31/2005 at 07:58 PM |
|
|
:(
I just read the Defining Dependencies post to the Tigra Form Validator Pro forum. Apparently there are too many possibilities to code dependencies
into this script.
|
|
|
cshanek
Junior Member
Posts: 4
Registered: 8/31/2005
Location: San Antonio
Member Is Offline
|
| posted on 8/31/2005 at 08:23 PM |
|
|
Sorry I keep replying to myself..
It seems as though accomodations could be made to the following code....// check reqired fields
if (this.a_fields[n_key]['r'] && !this.a_fields[n_key]['v']) {
this.a_fields[n_key].n_error = 1;
n_errors_count++;
}
to allow for something like...
'dependent':{'l':Dependent', 'r':true if form.dependee, 'f':'Dependent'}
What do you think?
|
|
|
cshanek
Junior Member
Posts: 4
Registered: 8/31/2005
Location: San Antonio
Member Is Offline
|
| posted on 9/6/2005 at 09:44 PM |
|
|
Last update.
For those of you who wanted to know I was able to impliment a way to allow for validation of dependent form elements.
Here is an example that I used. If my select box purchase was either 'Need to order' or 'Already have', I wanted to validate my textbox Afe to
insure it was not null. If the textbox reboot_time wasn't null, I wanted to ensure that my dropdown ampm was not null.
<script language="JavaScript">
var o_fields = {
'reboot_time':{'l':'Time','r':false,'f':'time','t':'v_reboot_time'}
}
//########### validate #############
function validate(f) {
if (f.purchase.options[f.purchase.selectedIndex].text == 'Need to Order' || f.purchase.options[f.purchase.selectedIndex].text == 'Already Have')
{
o_fields.afe = {'l':'Afe','r':true,'t':'afelab'}
}
if (f.reboot_time.value) {
o_fields.ampm = {'l':'AMPM','r':true}
}
var tfv = new validator('form', o_fields);
return tfv.exec();
}.
That's it. Though it is certainly not modular it is easy enough to update on a form by form basis.
|
|
|