LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 09-18-2003, 06:07 PM   #1
Linh
Member
 
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

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

<HEAD>
<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");

  }


</SCRIPT>
</HEAD>

<BODY>

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

</BODY>

</HTML>
 
Old 09-20-2003, 07:42 AM   #2
amirspl
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");
field.focus();
field.select();
}}

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
Linh
Member
 
Registered: Apr 2003
Posts: 178

Original Poster
Rep: Reputation: 30
reply to amirspl

Hi amirspl. Thank you so much for your help.
 
  


Reply


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


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

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