•
•
•
•
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
![]() |
•
•
Join Date: Oct 2004
Posts: 3
Reputation:
Rep Power: 0
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
•
•
Join Date: Dec 2003
Location: Nashville, TN
Posts: 2,333
Reputation:
Rep Power: 11
Solved Threads: 102
•
•
Join Date: Jun 2004
Location: Worcester, Massachusetts
Posts: 180
Reputation:
Rep Power: 5
Solved Threads: 3
•
•
•
•
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
•
•
Join Date: Jun 2004
Location: Worcester, Massachusetts
Posts: 180
Reputation:
Rep Power: 5
Solved Threads: 3
For the client, it's no difference whether the script is parsed on the server (php) or runs on the client (JavaScript).
Michael
Michael
•
•
Join Date: Jun 2004
Location: Worcester, Massachusetts
Posts: 180
Reputation:
Rep Power: 5
Solved Threads: 3
•
•
•
•
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
•
•
Join Date: Oct 2004
Posts: 3
Reputation:
Rep Power: 0
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.
•
•
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 338
Reputation:
Rep Power: 4
Solved Threads: 2
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.
if (strlen(trim($user_input)) < 1)
{
echo "hey STUPID finish the form";
}![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the PHP Forum
- Previous Thread: Help ! I need help starting up on Php !
- Next Thread: File Handling Help NEEDED



Linear Mode