You are here: Re: Form validation with PHP/Javascript « PHP Programming Language « IT news, forums, messages
Re: Form validation with PHP/Javascript

Posted by Chris on 08/16/06 17:48

"Randy Webb" <HikksNotAtHome@aol.com> wrote in message
news:OPidnYDZHIUQzH_ZnZ2dnUVZ_v6dnZ2d@comcast.com...
> Chris said the following on 8/15/2006 6:12 PM:
>> "Rik" <luiheidsgoeroe@hotmail.com> wrote in message
>> news:<8e84e$44e23d2f$8259c69c$14497@news1.tudelft.nl>...

>>
>> I don't understand your statement - "js has absolutely nothing to do with
>> the PHP which created it".
>
> If you don't understand that statement, you need to take a good class on
> HTTP.

That may be so, but I haven't seen any such classes available at my college,
and even if there were, I don't have the time to take one now.

>> My problem isn't the js - it works okay on a non-php generated form -
>
> Yes, your problem is the js. If it works on a "non-php generated form"
> then it will work on a PHP generated form providing PHP doesn't change the
> names/ID's.
>

There may have been an error in it - but if you visit a few sites regarding
form validation with PHP and JS they show the same essential layout - in
fact, what I had included was a copy & paste from a tutorial - only changing
the name of the form element itself.

>> I have used js to validate html forms in the past with no problem.
>
> With just the snippet quoted in the previous post, I find that a dubious
> claim that I don't believe.

You are just being rude here.

>> The question is how to work with PHP and js together - a commonly asked
>> question in forums.
>
> And you will get two replies to that question:
>
> 1) They are unrelated other than being on the opposite ends of a stateless
> HTTP Connection.
> 2) Some utter garbage that doesn't resemble the truth.
>

Please see the following sites:
http://www.phpdebutant.com/articles/PHP-form-validation.phphttp://www.php-mysql-tutorial.com/form-validation-with-php.phphttp://www.onlamp.com/pub/a/php/2004/04/22/php_css_forms.htmlThese
are all slightly different approaches, but they all refer to the use of both
PHP and js being used together to validate forms.I was looking for advice
for what approach has proven to work best when much of the data in the
initial form is php-generated (such as populating the list boxes).
>> There are ways to pass the variables back and forth, etc. which I have
>> used elsewhere in my application.
>
> Really? And you don't understand form validation using JS and that PHP has
> nothing to do with it? Impressive.
>

Again - very rude. I never said that PHP had anything to do with JS or
vice-versa - I simply wanted to
know the best way to use both together to validate a form.

>> But I haven't seen anything regarding form validation when the form is
>> PHP and the validation is js.
>
> That is because JS doesn't know, and doesn't care, what server side
> language generated it. It's irrelevant.
>
>

Rude again
<snip>
>
>> That's my concern as I know that PHP is server-side and processes before
>> data goes to the browser. So - how to intercept the data as it goes from
>> the browser to the server?
>
> You use JS and the onsubmit event handler. Once it is submitted, JS can't
> touch it.
>

correct - because js is client-side, but I noted that the onsubmit event
handler didn't find the js function. That is why I even posted my question
in the first place. Our site has a header automatically prepended,
therefore, it's very likely didn't have the js in the correct spot so that
it can be called from the very top of the page (within the initial head
tags) - perhaps as an external js file.

>> I'm sure this is a fairly simple process, since there are tons of PHP
>> forms out there that get validated. Perhaps incorporate the js into the
>> processing page at the very beginning?
>
> Nope.
>
>> Does this look like reasonable workable logic?
>
> Not even close.
>

See the above-referenced sites.

> --
> Randy
> comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
> Javascript Best Practices -
> http://www.JavascriptToolbox.com/bestpractices/

It surprises me that some of the people in newsgroups are so rude to those
of us who are simply asking questions because we don't understand or would
like further clarification on how to approach something. If we were all php
or js gurus, we wouldn't be posting questions here. Perhaps I don't
understand the purpose of a newsgroup - I thought it was to share
information, not belittle people.

Christina

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация