473,396 Members | 1,748 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,396 software developers and data experts.

Control charcters in form input field

Hello!

In a form I have an input field. It's supposed to get input form a
scanning device. Thus, the input might contain special characters (like
the Group Separator in a EAN barcode). Now, I want to manipulate a
little with the input in a javascript, but I'm not able to find the
Group Separator:

input = document.main.input.value;
var a = input.split("");
var i;
for(i=0;i<a.length;i++) {
if(/\x1D/.test(a[i])) {
alert("GS");
}
}

This is a snip that parses the input, character by character, and gives
me an alert if the Group Separator (Hex: 1D) is found. But it never
matches, even if I know that the input string contains in. I have a
similar script written in Perl, an that script finds the Group Separtor.

What can I do to find the %"#€ Group Separator??

Thnx in advice!
- Paul Jørstad

Jul 20 '05 #1
4 5626
Paul Jørstad <pa***@onlineREMOVE.no> wrote in message news:<Tc*******************@news4.e.nsc.no>...
Hello!

In a form I have an input field. It's supposed to get input form a
scanning device. Thus, the input might contain special characters (like
the Group Separator in a EAN barcode). Now, I want to manipulate a
little with the input in a javascript, but I'm not able to find the
Group Separator:

input = document.main.input.value;
var a = input.split("");
var i;
for(i=0;i<a.length;i++) {
if(/\x1D/.test(a[i])) {
alert("GS");
}
}

This is a snip that parses the input, character by character, and gives
me an alert if the Group Separator (Hex: 1D) is found. But it never
matches, even if I know that the input string contains in. I have a
similar script written in Perl, an that script finds the Group Separtor.

What can I do to find the %"#€ Group Separator??

Thnx in advice!
- Paul Jørstad


I can't help you, but the following displays matches for both x and y
in my quick test in IE6 and Netscape 7:

<script type='text/javascript'>
function f(){
var x = txt1.value;
var y = '\x1D';
var s = '';
if(/\x1D/.test(x)) {
s += "x matches";
}else{
s += "x does not match";
}
s += '\n';
if(/\x1D/.test(y)) {
s += "y matches";
}else{
s += "y does not match";
}
alert(s);
}
window.onload = function(){
window.form1 = window.form1 || document.getElementById('form1');
window.txt1 = window.txt1 || form1.elements['txt1'];
txt1.value = '\x1D';
}
</script>
<form id='form1' name='form1' action='a.htm' method='post'>
<input type='text' name='txt1' id='txt1' value='' />
</form>
<br>
<a href='b.htm' name='a1' id='a1' onclick='f(); return false;'>f()</a>

Not an expert. FWIW.
Jul 20 '05 #2
JRS: In article <Tc*******************@news4.e.nsc.no>, seen in
news:comp.lang.javascript, Paul Jørstad <pa***@onlineREMOVE.no> posted
at Wed, 17 Sep 2003 15:20:50 :-
In a form I have an input field. It's supposed to get input form a
scanning device. Thus, the input might contain special characters (like
the Group Separator in a EAN barcode). Now, I want to manipulate a
little with the input in a javascript, but I'm not able to find the
Group Separator:

input = document.main.input.value;
var a = input.split("");
var i;
for(i=0;i<a.length;i++) {
if(/\x1D/.test(a[i])) {
alert("GS");
}
}

This is a snip that parses the input, character by character, and gives
me an alert if the Group Separator (Hex: 1D) is found. But it never
matches, even if I know that the input string contains in. I have a
similar script written in Perl, an that script finds the Group Separtor.


Substituting the first line, it works for me in MSIE4. Can you be
certain that the GS is really present? Compare the lengths of var input
and of var a with the expected character count.

It also works using the RegExp to test var input directly, without
split.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #3

Dr John Stockton wrote:
Can you be certain that the GS is really present?


In fact I'm not sure.. If I parses the input from the scanner in a
perl-script reading from stdin, I got this:

$ perl input.pl

S > 83
? > 29
2 > 50

First character is "S", which is ASCII value 83. As, you see, the second
character is the GS having ASCII value=29. The exact same input is put
into the form element, but then the GS is gone for some reason. If I do
a split(""), and alerts every character, the GS never pops up. So it
seems that the browser is the problem, ripping of special characters,
ie. the input field can't receive control characters.

- paul

Jul 20 '05 #4
Hi,

You might try hooking into one of the browser's onkeyxyz events (up|down|press).

If you have an "onpaste" event available to you, that's another possibility.

I'm just taking wild guesses at how the barcode info is getting into your web page.

good luck!
Jul 20 '05 #5

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

Similar topics

5
by: F. Barth | last post by:
Hello, I've posted this problem to one other newsgroups, and gotten some diagnostic help, but I still need a solution. The full text of the message box is: "The field is too small to accept the...
2
by: Softwaremaker | last post by:
Hi all, I have created a Windows Form control that runs on a web form. This control is a composite control comprising of other textboxes (public scope). This control inherits from the...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
4
by: Ryan Ternier | last post by:
Hello, I have a repeater control that does the following on the ItemDataBound event. It works perfectly, except that when it prints out, the names of the controls aren't what I'd expect. ...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
3
by: cindy | last post by:
I have a web form “Form1” with a panel. Inside the panel is a datalist. One of the items displays the field value “xyz” from the dataset. If the field is null the user clicks on a...
1
by: EricRybarczyk | last post by:
I am starting a rewrite of an existing Classic ASP web site in ASP.NET 2.0. The existing ASP application has several types of users, each with a separate login process (separate login page,...
4
by: Ronald Raygun | last post by:
I have a form on an HTML page with the usual user name, email etc. I want to be able to display a popup window (callout?) when a text input control element is clicked. For example, for the form:...
3
by: Allen Chen [MSFT] | last post by:
Hi Richard, Quote from Richard================================================== However I also want to be able to remove the panes. I have tried to include this, but find that when I first...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.