On Thu, 03 Feb 2005 07:23:21 -0700, Don <no@adr.com> wrote:
[color=blue]
>Can't figure this one out. The "validate" function below checks to make sure the field "names" is
>not null. "validate" actually calls "isEmpty", which scans the field.
>
>Here's the situation. <input> for "names" first existed in an html file. The test worked just fine
>there. If the field was filled, the test would pass. If the field was cleared after having been
>filled, it would fail as it should.
>
>The field is then passed, via POST, to a PHP script, where it is checked for non-null in the same
>manner using the code below. The same field content appears when the page is returned to the
>client. The only thing is if I clear the field, the JavaScrpt function "validate" thinks the field
>is still non-null, and the test passes when it should have failed. Any idea what's going on here?
>
>Thanks for your help,
>Don
>
>
>//
>// Define whitespace characters
> var whitespace = " \t\n\r";
> function isEmpty(s)
> {
> var i;
> if((s==null) || (s.length == 0))
> return true;
> // Search string looking for characters that are not whitespace
> for(i=0; i <s.length; i++)
> {
> var c = s.charAt(i);
> if(whitespace.indexOf(c) == -1)
> return false;
> }
> // All characters are whitespace.
> return true;
> }
>//
>//
> function validate()
> {
> if(isEmpty(document.online_registration_form_calc. names.value))
> {
> alert('Entry in "Name\(s\)" field required.');
> document.online_registration_form_calc.names.focus ();
> return false;
> }
> return true;
> }
>
>
><?php
> print("<input name=\"names\" type=\"text\" id=\"names\" value=\"".$_REQUEST['names']."\"
>size=\"97\">\n");
>?>
>
>----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
>
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
>----= East and West-Coast Server Farms - Total Privacy via Encryption =----[/color]
Never mind. I found my problem. Can't believe I did this. Wasn't using the correct <form> name on
the second validation pass.
Thanks anyway.
Don
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----