473,386 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Javascript for Netscape onKeyPress

hai !

I have one textbox which accepts only alphanumeric values. How to restrict the textbox to allow only alphanumeric values in keypress event. It works well in IE. But it wont work in netscape 8.1. pl provide script.

Thanks
Mar 1 '06 #1
2 6733
Banfa
9,065 Expert Mod 8TB
You should have posted your script code so we could have pointed out the problem more easily.

However I am going to take a guess that your code doesn't check to see which browser it is running on. The problem is that the event object is not standard across browsers and the way to access the key being pressed is different, look at this example and see if it helps

[html]
<html>
<body>
<script type="text/javascript">
function noNumbers(e)
{
var keynum
var keychar
var numcheck

if(window.event) // IE
{
keynum = e.keyCode
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which
}
keychar = String.fromCharCode(keynum)
numcheck = /\d/
return !numcheck.test(keychar)
}
</script>

<form>
<input type="text" onkeypress="return noNumbers(event)" />
</form>

</html>
[/html]

This example comes from http://www.w3schools.com/jsref/jsref_onkeypress.asp
Mar 1 '06 #2
hi It works fine for only one condition ie accepts number or aplphabets.

But it wont accept alphanumeics. I had found the code for accepting alphanumeric values only.

thanks for ur code.

Bye
Mar 2 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Fred Brown | last post by:
Hi, I want to cancel a certain key in JavaScript. To do so, I catch the event in OnKeyPress and cancel the default: <head> .... function f(evt) { var evt = (evt) ? evt : ((window.event) ?...
4
by: joebob | last post by:
The following script if run in Internet Explorer should display a thumbview of a webpage that you point it to. To test it, replace test.htm with a valid html file. The problem I'm having is that...
4
by: Jonas | last post by:
Hi! I have a web page where I want to intercept keypress events in an INPUT-tag and check if it is the Enter key, which calls another function that executes a search. My code runs on Netscape 7...
3
by: mgw | last post by:
Hi, I'm trying to cancel the Shift+F3 key combination in Netscape 7.2 from performing the F3 key's default action of opening the Find dialog. I'm unable thus far to prevent the Find dialog from...
3
by: Ben | last post by:
Here's my form: <form name="aForm" method='post'> <input type=file name=file1 onkeypress='KeyPress()'><br> <a id='attachMoreLink' href='javascript:AddFileInput()">Attach More Files </a> <input...
8
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);"...
1
by: gautam.chavan | last post by:
hello all, In INTERNET EXPLORER 6, on pressing the Enter Key, either the page is Submitted or the onKeyDown/onKeyPress is invoked. IN NETSCAPE 4.78 on a solaris platform, the same does not...
3
by: jason | last post by:
I have a very simple asp.net 2.0 page with one textbox that onkeyPress is suppose to do some check of what was typed. Below is the source showing the javascript function is available. The minute I...
5
by: Morten Snedker | last post by:
I'm not that great at reading javascripts. Instead of doing nothing I'd like to return a Tab-character, if Enter occurs: <script language="javascript" type="text/javascript" > //disable...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.