xizwyck
Junior Member
Posts: 2
Registered: 5/13/2008
Member Is Offline
|
posted on 5/13/2008 at 08:24 PM |
|
|
Select Menu Not Recognized
For some reason, the select menu (drop down list), name/id is not recognized by the script. The name element is correct. The a_fields var is also
correct. The form name is also correct. The validation works for the other elements but not this one... it says it can't find it. Any ideas?
|
|
xizwyck
Junior Member
Posts: 2
Registered: 5/13/2008
Member Is Offline
|
posted on 5/14/2008 at 12:23 AM |
|
|
I found that the script breaks when the select tag is set to multiple. Does anyone know of a fix for this?
|
|
Hollstar
Member
Posts: 11
Registered: 4/4/2008
Location: Australia
Member Is Offline
|
posted on 6/3/2008 at 02:40 AM |
|
|
Quote: | Originally posted by xizwyck
I found that the script breaks when the select tag is set to multiple. Does anyone know of a fix for this? |
You can't "fix" this problem...
The JavaScript validator is only designed to handle a select box where you can only select one item. The value of this item is then checked to ensure
it is not a null value (Line 120 in validator.js). If you were to change this, normal select or drop down boxes would not work. One should also
consider the fact that the min/max variable will also fail to work. In some cases you may want to ensure the user has selected a certain number of
options. Again, this is something which fails to work for the above reason!
Considering this script was developed back in August 2005, I doubt Soft Complex are going to make this addition despite how fantastic it would
be...
The only solution in my eyes is to run a seperate validation prior to running the Tigra validator...
Good Luck! :)
|
|
Hollstar
Member
Posts: 11
Registered: 4/4/2008
Location: Australia
Member Is Offline
|
posted on 6/3/2008 at 03:14 AM |
|
|
Quote: | Originally posted by Hollstar
The only solution in my eyes is to run a seperate validation prior to running the Tigra validator...
|
I lie, that wasn't 100% true... :)
Allow me to explain my situation so you have a clear picture of what I've just done:
I had a drop down select box with the numbers 0 through to 5. The number the user selected was the required min & MAX of the the TOTAL number of
options the user MUST select in another multi-select/list box.
What I've done is used the "Compare" feature of this script, designed for passwords, to get around this problem.
What you need to do is place either one or two hidden form elements on the page in question. Then you will need to write some code which interacts
with your select/list box which either adds plus one (1), or subtracts one from the hidden field!
Then you simply add two new lines to the Tigra Form Validator asking them to compare the two hidden fields. If the numbers don't add up, then an
error is produced.
I hope this helps you! :) Good Luck...
|
|
tonym
Newbie
Posts: 1
Registered: 6/25/2008
Member Is Offline
|
posted on 6/25/2008 at 10:36 PM |
|
|
I fixed the problem by changing line 121 from
else if (o_input.options) // select
to
else if (o_input.options && !o_input.multiple) // select
This makes sure to only use the option list if the select is not multiple. If it is multiple, it just uses the field value, which will be an empty
string if nothing is selected. This makes sure the user selects at least one item, but does nothing to help if you want them to select a certain
number of items. In that case, Hollstar's solution may be better. Also, this won't work in old Netscape browsers, but our requirement here is
support for IE6+, all FF, Safari, and Opera. The code works in all these browsers.
|
|