Developing Matt

My Technical Journal

A form for accountants: enter key and numbers

leave a comment »

It’s been a while since I’ve worked with javascript. For some reason I always begrudge it, which is strange because it is such a fun programming medium. I forget how fun it is because it’s so instantaneous.  That’s the beauty behind javascript. So here’s what I’ve been working with. I found three files that work together to give some great functionality. You can download the three javascript files and include a reference to them in your sourcecode.

<script type =”text/javascript” src=”detect.js”></script>
<script type=”text/javascript” src=”eventutil.js” ></script>
<script type=”text/javascript” src=”textutil.js” ></script>

1. How to allow specific characters only: Add two elements to your textbox

validchars=”0123456789″
onkeypress=”return TextUtil.allowChars(this,event)”

2. How to capture the enter key and replace it with a tab key (so your form operates more like a 10 key program for accountants). Add one element to your textbox

onkeydown=”if (event.keyCode==13) {event.keyCode=9; return event.keyCode }”

Advertisements

Written by matt

September 11, 2007 at 1:36 pm

Posted in Asp.net, javascript

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: