Hello,
OK, almost there. Here's what I have so far, which handles characters
as they're typed in. Could someone please show me how I would loop
through all the values that are entered if a block of text was pasted
in, and then grab the ascii value(s) that are > 128?:
<script type="text/javascript">
function toASCII(s)
{
var r = [];
for (var i=0, j=s.length; j--; i++){
r[i] = s.charCodeAt(i) ;
if (r > 128)
{
alert('"' + String.fromChar Code(r) + '"' + " Is not an acceptable
character.");
document.form1. textarea1.value ="";
document.form1. textarea1.focus ();
return false;
}
else
{
return true;
}
}
//return r.join(' ');
}
</script>
<BODY>
<form name="form1">
<textarea name="textarea1 " onBlur="toASCII (this.value);"> </textarea>
<!--<textarea name="textarea1 "
onBlur="onBlur= "document.getEl ementById('xx') .innerHTML =
toASCII(this.va lue);"></textarea>-->
<br>
<div>ASCII character codes
<!--<div id="xx"></div>-->
</div>
<input type=reset value="clear" onClick="docume nt.form1.reset( )">
</form>
</BODY>
Thanks in advance,
KP 1 4225
Kermit Piper wrote: OK, almost there. Here's what I have so far, which handles characters as they're typed in. Could someone please show me how I would loop through all the values that are entered if a block of text was pasted in, and then grab the ascii value(s) that are > 128?:
There are no "ASCII values" beyond code point 127, ASCII is a 7-bit code.
And most certainly you mean > 127.
<script type="text/javascript"> function toASCII(s)
See above.
{ var r = []; for (var i=0, j=s.length; j--; i++){
The value of `i' will be always what s.length-j evaluates to, so one of both
variables is redundant.
r[i] = s.charCodeAt(i) ;
OK, you are creating a new array element with the value of the code of the
character at position `i'.
if (r > 128)
But `r' refers to an Array object. It cannot work this way.
{ alert('"' + String.fromChar Code(r) + '"' + " Is not an acceptable
It would be more simple/easier/better if you just used s.charAt(i) here.
character.");
Use multiples of two spaces to indent your code, not the Horizontal Tab
character. Avoid code that exceeds the 80-columns margin, especially when
posting it; 72 or 76 are good numbers. IIRC there is a documentation
standard that even calls for word wrap after column #67.
document.form1. textarea1.value =""; document.form1. textarea1.focus ();
See below.
return false; } else { return true; } } //return r.join(' '); } </script>
<BODY> <form name="form1">
The `action' attribute is missing.
<textarea name="textarea1 " onBlur="toASCII (this.value);"> </textarea>
Do not validate `onblur'. Use a button to validate instead. That can also
be a submit button in which case you would use the `onsubmit' handler of
the `form' element instead of the `onclick' handler of the button.
Pass `this' instead of `this.value', and you can use the `form' property
(or the passed reference itself, if called from an event handler for the
`form' element), coding standards compliant and avoiding any dependency
on the `form' element's name.
Search the archives for "form validation".
[...] <input type=reset value="clear" onClick="docume nt.form1.reset( )">
The `onclick' code here is nonsense, since it is already a reset
button (input[type=reset]). Remove the entire attribute.
PointedEars This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: DenoxiS |
last post by:
Hi,
I've been working on a project that will help me save some time. It
basically reads a URL and saves it to disk as an html file. In other
words, I just wanted to make the automated version of "Save As -> HTML
Only" command on Internet Explorer.
I use XMLHTTP component for this task. I created 3 functions:
readURL: Reads the given URL using Microsoft.XMLHTTP component and
returns the content.
|
by: Mervyn Carter |
last post by:
Dear Friends
IE5+, Win9*, not Netscape - I understand getSelection() is Netscape
only.
Anyone know of a way to access an area of mouse selected text within a
<SPAN> or <DIV> ( ie not in a form/input/text area tag) and assign it to
a variable ?
I can't seem to find a way in my reference book, or online, or by trial
|
by: Todd Perkins |
last post by:
Hello all, surprisingly enough, this is my first newsgroup post, I usually
rely on google. So I hope I have enough info contained. Thank you in
advance for any help!
Problem:
I am getting this error when I try to pull up my edit page to display the
current database information in the form, and then edit it on click:
|
by: gar |
last post by:
Hi,
I need to replace all the double quotes (") in a textbox with single quotes ('). I used this code
text= Replace(text, """", "'"
This works fine (for normal double quotes).The problem comes in when you copy a double quote from MS Word and paste it in the text box. What happens is the double quote becomes slanted (“) so my code above can't filter it. I tried to do this
text= Replace(text, "““","'")
|
by: Kermit Piper |
last post by:
Hello,
I have a function that lets me convert one character and throw an alert
with the corresponding ASCII value, but what I am having trouble with
is applying it to a text box. What I'm trying to do is when characters
are entered the function will loop through the entered values and throw
an alert for each of the corresponding ASCII values for each of the
characters entered. I am trying to alert the user for every character
that is...
| |
by: Jeffrey Spoon |
last post by:
Hello, I'm a bit stuck trying to convert a text file which contains
extended ASCII text and changing the ASCII values so they become
readable. I do this by subtracting 127 from the ASCII value. However, at
the moment I am just getting more gibberish so I'm probably doing
something wrong. I tried using ASCII Encoding before to get the ASCII
values. Although this worked for 0-127 ASCII values, extended ASCII gave
strange values (such as 1992...
|
by: davetelling |
last post by:
I am a total newbie, trying to slog through the Visual C# Express
application. I need to be able to convert a single ASCII character (can be
anything from 0 to 255) to an int for use in other places. So far, I cannot
find anything that works. My application gets a string of characters from an
external device via the serial port. I can use the substring method to get
just one character from that input string, and I need to be able to convert...
|
by: meendar |
last post by:
Hi,
I am having a character pointer which contains ascii values. i just
want to convert all these ascii values to respective characters and
again store it in another character pointer.
Anybody please help in c language.
Thanks in Advance.
|
by: Catalyst159 |
last post by:
I have a form which is used to calculate residential Floor Area Ratio (FAR). The form is structured into seven parts as follows:
Part A: Maximum FAR and Floor Area:
Part B: Gross Floor Area of the main floors of the main house:
Part C: Gross Floor Area of the basement or cellar:
Part D: Gross Floor Area of the attic:
|
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |