| View previous topic :: View next topic |
| Author |
Message |
tom fallow
Joined: 30 Dec 2005 Posts: 27 Location: PA
|
Posted: Sun Jan 01, 2006 2:00 am Post subject: Needing help with alerts on registration page. |
|
|
I am working in PHP and am trying to set up my registration page with javascript alerts for blank fields, too little characters, wrong characters, etc. I have utilized this code:
if (empty($firstname))
{
echo "
<script type = 'text/javascript'>
alert('Please enter your first name.');
</script>";
}
However, when I use this and preview the page using IE, the alert comes up as the page is loading! Is there anyway to make these alerts appear after the submit key is hit?
Thanks,
Tom |
|
| Back to top |
|
 |
Fed Site Admin

Joined: 12 Aug 2005 Posts: 176
|
Posted: Thu Jan 05, 2006 11:56 am Post subject: |
|
|
hey tom, welcome to the forums...
well, basically what you're doing wrong is that you are using echo to write out a javascript instruction, if you want your alert to be displayed when your visitor hits the button, you simply have to put the javascript instruction without any echo
you might want to have a look at this thread where we check if a box is checked and eventually alert the user with javascript
http://www.tutorialstream.com/forums/viewtopic.php?t=37 |
|
| Back to top |
|
 |
tom fallow
Joined: 30 Dec 2005 Posts: 27 Location: PA
|
Posted: Tue Jan 10, 2006 9:49 pm Post subject: |
|
|
| Thanks for the hand, Fed. With your help, managed to figure it out! |
|
| Back to top |
|
 |
|