Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > How to prevent Form submission if users hit enter.

Reply
Thread Tools

How to prevent Form submission if users hit enter.

 
 
Pamela Chatterjee
Guest
Posts: n/a
 
      10-23-2003
In my Web Form I have more than one Textbox for user input. If I hit
enter to any Textbox its submitting the form. How can I prevent Form
submission if users hit enter to the textbox? I want to submit the
form only when user will hit submit button.

Thanks for any help.
 
Reply With Quote
 
 
 
 
kaeli
Guest
Posts: n/a
 
      10-23-2003
In article <(E-Mail Removed) >,
http://www.velocityreviews.com/forums/(E-Mail Removed) enlightened us with...
> In my Web Form I have more than one Textbox for user input. If I hit
> enter to any Textbox its submitting the form. How can I prevent Form
> submission if users hit enter to the textbox? I want to submit the
> form only when user will hit submit button.
>
> Thanks for any help.
>


You capture the enter key.
That's been posted on this group before, several times. Take a look at
the archives on google. You have to worry about browsers with that one.
So keep in mind your target browsers.

You also break functionality a user is used to (the browser is SUPPOSED
to do that and some people count on it) - not a good thing for general
internet applications, acceptable for intranet apps, CD-ROMs, or
games...
Always remember that internet applications can be accessed by anyone
with any browser - including those browsers modified or created for the
disabled. Disabling functionality may render your site inaccessible to
the disabled.

-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      10-23-2003
(E-Mail Removed) (Pamela Chatterjee) writes:

> In my Web Form I have more than one Textbox for user input. If I hit
> enter to any Textbox its submitting the form. How can I prevent Form
> submission if users hit enter to the textbox? I want to submit the
> form only when user will hit submit button.


Why?

It is customary that browser forms are submitted by pressing return
in a text field. The user will be expecting it to happen. So, why
do you want to prevent the user from using the standard interface of
his browser?

If it is because you have, e.g., form validation code attached to
the submit button, then you should move that to the form elements
onsubmit handler instead.

/L
--
Lasse Reichstein Nielsen - (E-Mail Removed)
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Prevent form submission only from default action Stanimir Stamenkov Javascript 13 03-20-2008 07:15 PM
Can't hit the site by name but I can hit by IP CK ASP .Net 9 10-19-2006 08:01 PM
prevent form submission with dynamic onsubmit? nybble Javascript 1 10-02-2005 05:26 PM
Form Submission: Final URL that has form options included ?? Jared Javascript 5 07-10-2003 10:33 AM



Advertisments