| | |
"hey STUPID finish the form" function?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2004
Posts: 3
Reputation:
Solved Threads: 0
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
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
•
•
•
•
Javascript can do it
@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:
PHP Syntax (Toggle Plain Text)
if (!$_POST['fieldname']) { echo "<div style='color:red'>"."Please fill out this field!"."</div>"; }
That's it basicly.
Michael
For the client, it's no difference whether the script is parsed on the server (php) or runs on the client (JavaScript).
Michael
Michael
•
•
•
•
I think he wanted a client side solution to his problem
Michael
•
•
Join Date: Oct 2004
Posts: 3
Reputation:
Solved Threads: 0
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.
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.
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.
the trim functions is used to make sure they didnt just enter spaces as there input.
PHP Syntax (Toggle Plain Text)
if (strlen(trim($user_input)) < 1) { echo "hey STUPID finish the form"; }
![]() |
Other Threads in the PHP Forum
- Previous Thread: Help ! I need help starting up on Php !
- Next Thread: File Handling Help NEEDED
| Thread Tools | Search this Thread |
apache api array auto beginner binary broken cache cakephp checkbox class cms code codingproblem cron curl customizableitems database date display dynamic echo email error errorlog file files filter folder form format forms forum function functions gc_maxlifetime global google headmethod href htaccess html image include insert ip javascript joomla limit link login mail malfunctioning memmory memory menu method mlm multiple mysql nodes oop parameter parsing paypal pdf php phpmysql popup query radio random recursion recursiveloop remote script search select server sessions snippet source space sql static survey syntax system table trouble tutorial up-to-date update upload url validator variable video web youtube






