| Home  |  | About  |  | Contact  |  | Board index » PHP contact form » About code and modifications 
Register  |   FAQ   |  Search  |  Login
Host : WEBHOSTINGPAD.COM
  • Free domain name
  • Unlimited Disk Space
  • Unlimited Bandwidth
  • Unlimited sub domain
  • Host unlimited domain
  • Unlimited MySql database
  • Unlimited Parked Domains
  • SSI (Server Side Includes)
  • Weekly Backups
  • And much more..
  • 1.99 USD per month

Visit : webhostingpad.com

Hosting: Free trial
FatCow is one of the leading webhost in the internet today. FatCow Web Hosting. Free Trial , Free Setup, Free Support, All risk free!
Visit: FatCow.com


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Prevent form submission from return/enter key
PostPosted: Mon Feb 08, 2010 6:42 pm 
Offline

Joined: Mon Feb 08, 2010 6:21 pm
Posts: 1
Sorry, i post this topic here; i'm using my own php contact form script at this moment. My question is how can i prevent Form Submission when User Presses the Enter / Return key on a text field?


Top
 Profile E-mail  
 
 Post subject: Re: Prevent form submission from return/enter key
PostPosted: Tue Feb 09, 2010 3:24 pm 
Offline
Site Admin

Joined: Wed Nov 05, 2008 8:04 am
Posts: 90
To disable enter key on form submission you have to use JavaScript. Add the following JavaScript code between <head> and </head> tag at the top of your contact form.
Code:
<script type="text/javascript">
<!--
var flag=false;
function setFlag(){flag=true;}
function getFlag(){return flag;}
-->
</script>

In your form tag add the following onsubmit event handler.
<form action= ...... onsubmit="return getFlag()">
In the submit button input add the following onclick event handler.
<input type="submit" value= ...... onclick="setFlag()" />
Now user can submit form only by clicking the submit button. Enter or Return key will not work.


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
©  2008,   http://ramui.com   All rights reserved.
Powered by phpBB