473,796 Members | 2,482 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Firefox: Filter Extended Ascii from Form

My appologies if this ends up being a duplicate post. For some reason the
first post never showed up.

I've tried about 300 iterrations of this same ability, and none of them seem
to work in Firefox. Take the following code for example. It WILL stop me
from entering zero into the first text box, but it wont stop me from
entering extended ascii characters (which is the final goal).

Two items of note:
1) Typing ALT+0156 inputs "o". And strangely enough the statusbar text gets
set to "ALT0moz2 ALT0moz2 ALT0moz2". Only 3 ALT sequences show up when I
actually type 4 characters
2)Im working on a laptop that has no true numpad, so the '0' may be a result
of me having to hold down a special function key in order to enable a numpad
overlay.). So the check for altKey is correctly working, but attempting to
cancel the ALT event fails.

Does anyone know what is wrong with this, or have a working example that
stops ALT keypresses / Extended chars in FIREFOX ?
<script type="text/javascript">
if(document.add EventListener){
document.addEve ntListener("key press", HandleEnterKey, true);
}
else{
document.attach Event("onkeypre ss", HandleEnterKey) ;
}
// Handle the enter key for a section of a form, binding it to the provided
submit buton
function HandleEnterKey( event) {
var nav = window.Event ? true : false;
if (nav) {
return NetscapeEventHa ndler_KeyDown(e vent);
} else {
return MicrosoftEventH andler_KeyDown( );
}
}

function NetscapeEventHa ndler_KeyDown(e ) {
if (e.which == 48) {
window.status = window.status + e.which + "moz1 ";
e.returnValue = false;
e.cancel = true;
e.preventDefaul t();
return false;
} else if (e.altKey) {
window.status = window.status + "ALT" + e.which + "moz2 ";
e.returnValue = false;
e.cancel = true;
e.stopPropagati on();
e.preventDefaul t();
return false;
}
return true;
}
</script>
</head>
<body>
<form action="" id="theForm">
<input type="text" id="i1" name="i1" />
</form>
Sep 17 '05
13 7780
Thanks! Thats exactly what I was wondering if you could do.
"Mick White" <mw***********@ rochester.rr.co m> wrote in message
news:59******** **********@twis ter.nyroc.rr.co m...
Baconbutty wrote:
To filter out, you could perhaps filter out from >126 as 127 is unused.

The reg exp woud be:-

var r=/[\x7F-\xFF]*/g;
s=s.replace(r," ");

Good, but this replaces control characters too (\x0 - \x1f )
Mick

Sep 19 '05 #11
Mick White wrote:
Baconbutty wrote:
To filter out, you could perhaps filter out from >126 as 127 is unused.

The reg exp woud be:-

var r=/[\x7F-\xFF]*/g;
s=s.replace(r," ");

Good, but this replaces control characters too (\x0 - \x1f )
Mick


Oops, ignore me.
Mick
Sep 19 '05 #12
Just thought I'd post an update. I got keypress filtering working finally.

For onblur handling (to cover paste ops) I ended up using the following.

if(/[\u0080-\uFFFF]+/i.test(targ.val ue)) {
window.status = "FAILED!"
} else {
window.status = "PASSED!"
}

This way higher unicode chars were included. I also opted against replace,
because if for example a person has 1 non-us english character in their
address, and I strip that character out, they may not visually see that its
missing, and it could lead to errors in the data. I am instead going to
alert() them to the error, and focus/select or highlight the offending
field.

Thanks for the help guys! I didnt realise you could regex based on char
code. Just what I needed in this situation. Very helpful!


"Mick White" <mw***********@ rochester.rr.co m> wrote in message
news:59******** **********@twis ter.nyroc.rr.co m...
Baconbutty wrote:
To filter out, you could perhaps filter out from >126 as 127 is unused.

The reg exp woud be:-

var r=/[\x7F-\xFF]*/g;
s=s.replace(r," ");

Good, but this replaces control characters too (\x0 - \x1f )
Mick

Sep 22 '05 #13
Strike that... I had to switch back to using the hex regex. The unicode
char set isnt layed out how I thought.
"bgbauer70" <us**@sbcglobal .net> wrote in message
news:zv******** *********@newss vr14.news.prodi gy.com...
Just thought I'd post an update. I got keypress filtering working
finally.

For onblur handling (to cover paste ops) I ended up using the following.

if(/[\u0080-\uFFFF]+/i.test(targ.val ue)) {
window.status = "FAILED!"
} else {
window.status = "PASSED!"
}

This way higher unicode chars were included. I also opted against
replace, because if for example a person has 1 non-us english character in
their address, and I strip that character out, they may not visually see
that its missing, and it could lead to errors in the data. I am instead
going to alert() them to the error, and focus/select or highlight the
offending field.

Thanks for the help guys! I didnt realise you could regex based on char
code. Just what I needed in this situation. Very helpful!


"Mick White" <mw***********@ rochester.rr.co m> wrote in message
news:59******** **********@twis ter.nyroc.rr.co m...
Baconbutty wrote:
To filter out, you could perhaps filter out from >126 as 127 is unused.

The reg exp woud be:-

var r=/[\x7F-\xFF]*/g;
s=s.replace(r," ");

Good, but this replaces control characters too (\x0 - \x1f )
Mick


Sep 22 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3852
by: wob | last post by:
Many thanks for those who responded to my question of "putting greek char into C string". In searching for an solution, I noticed that there are more than one version of "Extended ASCII characters"(No. 128 to 255) . e.g., in one version No. 224 is the symbol alpha, in another, it's a "a" with a ` on it... How come? You can see it here: http://www.kturby.com/cables/ascii2.htm
3
24528
by: JSM | last post by:
Hi, I am just trying to port an existing simple encryption routine to C#. this routine simply adds/substracts 10 ascii characters to each character in a text file (except quotes). The routine for decrypting the file works fine however when I encrypt the file, several characters are corrupted. when I looked into it they are always extended ascii characters (eg "x" which is ascii character 120 gets translated to ascii character 130 which...
6
14465
by: Mark Olbert | last post by:
The doPostBack javascript functioning is not submitting the page when called by linkbuttons (or an autopostback checkbox, for that matter). I'm aware of a problem with Netscape browsers and the postback code, but I have a workaround for that installed (and it looks like the code generated by ASP.NET when it renders the page does the same thing, namely, setting document<). However, the problem still exists under firefox. Has anyone come...
4
7236
by: =?Utf-8?B?Um9zaGFuIFIuRA==?= | last post by:
Hi All, I am new to C# programming; I am developing an application for recording audio data using voice modem. I am using HyperTerminal to manually process audio data. The modem when configured in voice record mode sends the audio (PCM) data on the serial port, few of the characters from these are in Extended ASCII range i.e. more than 127 decimal. In HyperTerminal we can reset the property to force the incoming data to 7 bit ASCII,...
13
48095
by: ramif | last post by:
Is there a way to print extended ASCII in C?? I tried to code something, but it only displays strange symbols. here is my code: main() { char chr = 177; //stores the extended ASCII of a symbol printf("Character with an ascii code of 177: %c \n", chr); //tries to print an ASCII symbol...
5
4021
by: DAHMB | last post by:
Hi all, Using Access 2007 I have a report called Sunday School Attendance based on a Query called qryAttendance the query is as follows: SELECT tblSundaySchoolAttendance.StudentID, tblSundaySchoolAttendance.AttendanceDate, . FROM tblSundaySchoolAttendance INNER JOIN ON tblSundaySchoolAttendance.StudentID=.StudentID;
5
3685
by: Jim Mandala | last post by:
Using Access 2003 front end; SQL Server 2005 Back end: I have a complex form that has lots of data fields including about thirty or so checkboxes storing Yes/No data that I would like my users to be able to use the Filter by Form functionality with to create a "Custom" query. This works perfectly fine when I filter on a text field. Also, this works perfectly fine for all data with an Access Back end. When I use boolean data and my SQL...
1
4225
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being aligned to the top, along with the slideshow and link buttons, you have to scroll down to see the text - how can I make IE6 display correctly? http://geekarama.co.uk/new_home.html here is the code for new_home.html and following that the CSS...
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9525
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10221
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.