Re: Javascript Alert
| From: | David Robley | Date: | Thu, 26 Oct 2000 04:26:29 +0000 |
| Subject: | Re: Javascript Alert | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-22042@lists.php.net to get a copy of this message | ||
On Thu, 26 Oct 2000, sannec27@eng.uab.edu wrote:
> Hi all,
>
> I am having a simple form which collects the age and name of the users. The
> names of First Name and Age fields are fn and age respectively. i want to
> pop up an alert box if somebody doesn't fill any of the two fields. I am
> trying with the following code but it is somehow not working:
>
> if (!$fn || !$age)
> <?php
> echo \"javascript:alert(\'Please fill in all the fields\')\";
> ?>
>
> Can any one please tell me what's the error in this line is.
>
> thanks
> Chakravarthy K Sannedhi
PHP is serverside and Javascript is client side. You need to write some
javascript that does ALL of the validation client side, if you want to
attempt to validate input before actually submitting the form. But do
ensure that you validate the input with PHP at the receiving point also -
if you just rely on JS to do validation you are asking for trouble.
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA