Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-18-2003, 06:07 PM   #1
Registered: Apr 2003
Posts: 178

Rep: Reputation: 30
Bug A Javascript that will not allowed alphabet character type into a text box

A Javascript that will not allowed alphabet character type into a text box. I cannot get it to work. When an alphabet character is pressed, nothing should be entered into the text box

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<TITLE>Map Drive Example</TITLE>
<SCRIPT lang="JScript">

function showDialog(txtDriveLetter)
    if (txtDriveLetter != 0 && txtDriveLetter != 1 &&
	txtDriveLetter != 2 && txtDriveLetter != 3 &&
	txtDriveLetter != 4 && txtDriveLetter != 5 &&
	txtDriveLetter != 6 && txtDriveLetter != 7 &&
	txtDriveLetter != 8 && txtDriveLetter != 9)
      alert("Only numeric is allowed");




  <LABEL for="txtDriveLetter" tabindex="3">Drive Letter:</LABEL> <INPUT type="text" id="txtDriveLetter" maxlength=2 onkeydown='showDialog(txtDriveLetter.value)'>


Old 09-20-2003, 07:42 AM   #2
LQ Newbie
Registered: Sep 2003
Location: australia
Posts: 8

Rep: Reputation: 0
function checkRefid(field) {
var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
if (ok == "no") {
alert("Invalid entry! Only characters and numbers (no spaces) are accepted! for a reference name");

Try this - place in the string valid only what you wish the user to use and you should be ok???
Old 09-22-2003, 12:15 PM   #3
Registered: Apr 2003
Posts: 178

Original Poster
Rep: Reputation: 30
reply to amirspl

Hi amirspl. Thank you so much for your help.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
installing redhat 8.0 when text login in I cannot type password?? I type root scrist Linux - General 4 04-22-2006 03:20 AM
What type of slashdot character are you? ProgramGeek General 7 07-26-2004 05:19 PM
I always have spaces between each character I type markraem Linux - General 2 01-26-2004 07:15 AM
Bug in Javascript Linh Programming 1 10-14-2003 01:38 PM
Bug in Javascript Linh Programming 2 09-23-2003 10:45 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:03 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration