"hey STUPID finish the form" function?

Reply

Join Date: Oct 2004
Posts: 3
Reputation: cheesywan is an unknown quantity at this point 
Solved Threads: 0
cheesywan cheesywan is offline Offline
Newbie Poster

"hey STUPID finish the form" function?

 
0
  #1
Dec 2nd, 2004
this may be more of an html question but relates to php...
I have a form with multipal text fields. when in any field you press the enter key the form is submitted to php, eventhou the form is not compleat.
what would be a method for detecting or traping this event?

is there a "hey STUPID finish the form" function?

thanks much
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: "hey STUPID finish the form" function?

 
0
  #2
Dec 2nd, 2004
Not knowing PHP, it'd probably be just an if statement of some sort, perhaps? If fieldname=NULL, then throw some kind of notification?
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 190
Reputation: Toba is an unknown quantity at this point 
Solved Threads: 4
Toba's Avatar
Toba Toba is offline Offline
Junior Poster

Re: "hey STUPID finish the form" function?

 
0
  #3
Dec 6th, 2004
Javascript can do it. Search google for it.
what? WHAT?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 204
Reputation: pcschrottie is an unknown quantity at this point 
Solved Threads: 8
pcschrottie's Avatar
pcschrottie pcschrottie is offline Offline
Posting Whiz in Training

Re: "hey STUPID finish the form" function?

 
0
  #4
Dec 6th, 2004
Javascript can do it
What if JavaScript is disabled?

@cheesywan

You can find your answer in probably every PHP-tutorial. If you send your form with the <form action="script.php" method="post"> tab, then you'll get a $_POST['fieldname'] for every field of your form. So you simply check if every field is complete:

  1. if (!$_POST['fieldname'])
  2. {
  3. echo "<div style='color:red'>"."Please fill out this field!"."</div>";
  4. }

That's it basicly.


Michael
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 190
Reputation: Toba is an unknown quantity at this point 
Solved Threads: 4
Toba's Avatar
Toba Toba is offline Offline
Junior Poster

Re: "hey STUPID finish the form" function?

 
0
  #5
Dec 8th, 2004
pcschrottie:

Yes, that's how I would do it server side. However, I think he wanted a client side solution to his problem (i.e. a box that pops up if you try without filling it out).
what? WHAT?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 204
Reputation: pcschrottie is an unknown quantity at this point 
Solved Threads: 8
pcschrottie's Avatar
pcschrottie pcschrottie is offline Offline
Posting Whiz in Training

Re: "hey STUPID finish the form" function?

 
0
  #6
Dec 8th, 2004
For the client, it's no difference whether the script is parsed on the server (php) or runs on the client (JavaScript).



Michael
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 190
Reputation: Toba is an unknown quantity at this point 
Solved Threads: 4
Toba's Avatar
Toba Toba is offline Offline
Junior Poster

Re: "hey STUPID finish the form" function?

 
0
  #7
Dec 8th, 2004
That's true for most people. People with slow connections will want it on the client.
what? WHAT?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 204
Reputation: pcschrottie is an unknown quantity at this point 
Solved Threads: 8
pcschrottie's Avatar
pcschrottie pcschrottie is offline Offline
Posting Whiz in Training

Re: "hey STUPID finish the form" function?

 
0
  #8
Dec 8th, 2004
I think he wanted a client side solution to his problem
I think the OT mentioned php, but hey, we are talking, and he isn't even responding.




Michael
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3
Reputation: cheesywan is an unknown quantity at this point 
Solved Threads: 0
cheesywan cheesywan is offline Offline
Newbie Poster

Re: "hey STUPID finish the form" function?

 
0
  #9
Dec 10th, 2004
thanks everone for your efforts, I have been distracted by personal events, and as programing and computing in general is not a daily profession for me I am alway as diligent in followups as I should be.
I was hoping that there would be some properity of html that would restrict the action of the enter key. if not, then java script seems like the way to go.
again thanks.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 348
Reputation: paradox814 is an unknown quantity at this point 
Solved Threads: 4
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: "hey STUPID finish the form" function?

 
0
  #10
Dec 12th, 2004
you can use a simple if-then function and a strlen to get the length of the text entered by the user

the trim functions is used to make sure they didnt just enter spaces as there input.

  1. if (strlen(trim($user_input)) < 1)
  2. {
  3. echo "hey STUPID finish the form";
  4. }
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC