K
Kermit Piper
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 = s.charCodeAt(i);
if (r > 128)
{
alert('"' + String.fromCharCode(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.getElementById('xx').innerHTML =
toASCII(this.value);"></textarea>-->
<br>
<div>ASCII character codes
<!--<div id="xx"></div>-->
</div>
<input type=reset value="clear" onClick="document.form1.reset()">
</form>
</BODY>
Thanks in advance,
KP
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 = s.charCodeAt(i);
if (r > 128)
{
alert('"' + String.fromCharCode(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.getElementById('xx').innerHTML =
toASCII(this.value);"></textarea>-->
<br>
<div>ASCII character codes
<!--<div id="xx"></div>-->
</div>
<input type=reset value="clear" onClick="document.form1.reset()">
</form>
</BODY>
Thanks in advance,
KP