Web Hosting Directory | Web Hosting Resources | Webmaster Resources | Domain Tools | Search Engine Marketing | Forums
  Signup
Today: 184   Yesterday: 1,303   Max: 2,773   Total: 530,517   Current Users : 20 (Member 0) 
DOMAIN TOOLS

WEBMASTER TOOLS

RELATED ARTICLES

SUBMIT AN ARTICLE

Write for us and get publicity, link to your website, and best of all get paid. Please visit our writers page for details.


LINK TO US

Link to us and earn points for each visitor you bring to us. Please visit our link partner page for details.

 

Canceling the Key Press

Before reading through this page, you might want to check out these solutions first:

If onKeyPress returns false, the event is cancelled and it's as if nothing is typed. For example, this code never allows you to type anything in the field.

this code produces this
<INPUT onKeyPress="return false">
type something:

Notice that the attribute starts with the word "return" which means that the rest of the statement is returned to the field object, canceling or allowing the event. Of course, it usually doesn't make sense to just never allow any typing, so you'll usually want to test if something is true or false. For example, you can only type in these fields if the Engineering checkbox is checked:

<INPUT TYPE=CHECKBOX NAME="engr"> Engineering<BR>
College: <INPUT NAME="college" onKeyPress="return this.form.engr.checked"><BR>
Focus:   <INPUT NAME="focus"   onKeyPress="return this.form.engr.checked">

Which gives us this form:

Engineering
College:
Focus:
Sometimes you want to allow or cancel the event based on which key was pressed. We show how to check which key was pressed in the next page.

Copyright 1997-2002 Idocs, Inc. Written by Miko Sullivan.

 
 
 
What is your major source of website traffic?
 
 
 
 
 
 

ADVERTISEMENT

 
Cheap Web HostingBudget Web HostingEcommerce Web Hosting
Link to UsLink ExchangeAdvertisePrivacy PolicyTerms Of ServiceAbout UsContact UsSitemap
Copyright © 2006 - 2009 Broadband Media, Inc. All rights reserved.