From: Thomas 'PointedEars' Lahn on
Richard Cornford wrote:

> Stefan Weiss wrote:
>> On 08/07/10 02:06, jr wrote:
>>> On Jul 7, 5:00 pm, Richard Cornford wrote:
>>>> jr wrote:
>>>>> else if (document.forms[0].search_zoneid.value != '' ||
>>>>> document.forms[0].search_zoneid.value != null ) {
>> [...]
>> I don't think an HTML form element can have a value of null
>> (i.e., exactly equal to null). I can't even think of a
>> situation where the value would not be a string.
>
> The - value - properties of Netscape <= 4 SELECT elements were always
> null (even after a selection had been maded).

But since it is known that the `value' property of those controls is not
interoperable (Netscape <= 4 notwithstanding), it should never be accessed
in the first place.

It is reasonable to assume that `document.forms[0].search_zoneid' (however
ill-advised that reference worm is, see the FAQ) refers to an object that
implements the HTMLInputElement interface. In that case it is more
important to make sure that both empty strings and whitespace values are
considered no-values, thus would cause form validation to fail:

if (!/\S/.test(….value))
{
// ...
return false;
}

However, the OP's description could be understood that they want to force
the user to enter the other value when the control for the one value is
clicked. Such an approach would certainly be ill-advised. Validation
should happen the moment before the form is submitted. It may happen before
that, but then the user must not be forced to enter a value (e.g., by
focusing the offending control automatically). The exception I would be
willing to accept is that if checking a checkbox or radiobutton required
another control to have a non-default value for the form to validate later,
that control may be focused automatically then, since that would help (and
not hinder) filling out the form using the keyboard.


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16