User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 423,653 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,131 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2476 | Replies: 9
Reply
Join Date: Oct 2004
Posts: 3
Reputation: cheesywan is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cheesywan cheesywan is offline Offline
Newbie Poster

"hey STUPID finish the form" function?

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2003
Location: Nashville, TN
Posts: 2,333
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Rep Power: 11
Solved Threads: 102
Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: "hey STUPID finish the form" function?

  #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  
Join Date: Jun 2004
Location: Worcester, Massachusetts
Posts: 180
Reputation: Toba is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 3
Toba's Avatar
Toba Toba is offline Offline
Junior Poster

Re: "hey STUPID finish the form" function?

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

Re: "hey STUPID finish the form" function?

  #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:

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

That's it basicly.


Michael
Reply With Quote  
Join Date: Jun 2004
Location: Worcester, Massachusetts
Posts: 180
Reputation: Toba is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 3
Toba's Avatar
Toba Toba is offline Offline
Junior Poster

Re: "hey STUPID finish the form" function?

  #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  
Join Date: Dec 2004
Posts: 204
Reputation: pcschrottie is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 8
pcschrottie's Avatar
pcschrottie pcschrottie is offline Offline
Posting Whiz in Training

Re: "hey STUPID finish the form" function?

  #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  
Join Date: Jun 2004
Location: Worcester, Massachusetts
Posts: 180
Reputation: Toba is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 3
Toba's Avatar
Toba Toba is offline Offline
Junior Poster

Re: "hey STUPID finish the form" function?

  #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  
Join Date: Dec 2004
Posts: 204
Reputation: pcschrottie is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 8
pcschrottie's Avatar
pcschrottie pcschrottie is offline Offline
Posting Whiz in Training

Re: "hey STUPID finish the form" function?

  #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  
Join Date: Oct 2004
Posts: 3
Reputation: cheesywan is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cheesywan cheesywan is offline Offline
Newbie Poster

Re: "hey STUPID finish the form" function?

  #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  
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 338
Reputation: paradox814 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 2
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: "hey STUPID finish the form" function?

  #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.

if (strlen(trim($user_input)) < 1)
{
  echo "hey STUPID finish the form";
}
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the PHP Forum

All times are GMT -4. The time now is 10:47 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC