473,326 Members | 2,010 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,326 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 5622
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.