lserrano
asked on
Sentence case
The following JS changes text input into Sentence case. But it only capitalizes the first word of the paragraph. Can you modify script so that the first letter of each sentnece is capitalized?
So, when I enter:
"yesterday i WENT To the STORe. it's an AWESOME store! very COOL."
Right now script fixes as:
"Yesterday i went to the store. it's an awesome store! very cool."
What I really need is:
"Yesterday I went to the store. It's an awesome store! Very cool."
Here's the script:
<script language="JavaScript">
<!-- Begin
function capsLc(){
if (navigator.appVersion.subs tring(0,1) =="2"){
navOld();
}
else navNew();
}
function navOld(){
txt=document.acc_form.desc ription.va lue+" ";
txt=txt.toLowerCase();
txtl="";
while ((txt.length>0)&&(txt.inde xOf(" ")>-1)){
pos=txt.indexOf(" ");
wrd=txt.substring(0,pos);
cmp=" "+wrd+" ";
if (tst.indexOf(cmp)<0){
ltr=wrd.substring(0,1);
ltr=ltr.toUpperCase();
wrd=ltr+wrd.substring(1,wr d.length);
}
txtl+=wrd+" ";
txt=txt.substring((pos+1), txt.length );
}
ltr=txtl.substring(0,1);
ltr=ltr.toUpperCase();
txtl=ltr+txtl.substring(1, txtl.lengt h-1);
document.acc_form.descript ion.value= txtl;
}
function navNew(){
txt=document.acc_form.desc ription.va lue+" ";
txt=txt.toLowerCase();
txtl="";
punc=",.?!:;)'";
punc+='"';
while ((txt.length>0)&&(txt.inde xOf(" ")>-1)){
pos=txt.indexOf(" ");
wrd=txt.substring(0,pos);
wrdpre="";
if (punc.indexOf(wrd.substrin g(0,1))>-1 ){
wrdpre=wrd.substring(0,1);
wrd=wrd.substring(1,wrd.le ngth);
}
cmp=" "+wrd+" ";
for (var i=0;i<9;i++){
p=wrd.indexOf(punc.substri ng(i,i+1)) ;
if (p==wrd.length-1){
cmp=" "+wrd.substring(0,wrd.leng th-1)+" ";
i=9;
}
}
if (cmp.indexOf(cmp)<0){
ltr=wrd.substring(0,1);
ltr=ltr.toUpperCase();
wrd=ltr+wrd.substring(1,wr d.length);
}
txtl+=wrdpre+wrd+" ";
txt=txt.substring((pos+1), txt.length );
}
ltr=txtl.substring(0,1);
ltr=ltr.toUpperCase();
txtl=ltr+txtl.substring(1, txtl.lengt h-1);
document.acc_form.descript ion.value= txtl;
}
// End -->
</script>
<FORM NAME="acc_form">
<CENTER>
<textarea NAME="description" ROWS=10></TEXTAREA>
<INPUT TYPE="button" NAME="html1" VALUE=" Submit " onClick="capsLc()">
</FORM>
</CENTER>
So, when I enter:
"yesterday i WENT To the STORe. it's an AWESOME store! very COOL."
Right now script fixes as:
"Yesterday i went to the store. it's an awesome store! very cool."
What I really need is:
"Yesterday I went to the store. It's an awesome store! Very cool."
Here's the script:
<script language="JavaScript">
<!-- Begin
function capsLc(){
if (navigator.appVersion.subs
navOld();
}
else navNew();
}
function navOld(){
txt=document.acc_form.desc
txt=txt.toLowerCase();
txtl="";
while ((txt.length>0)&&(txt.inde
pos=txt.indexOf(" ");
wrd=txt.substring(0,pos);
cmp=" "+wrd+" ";
if (tst.indexOf(cmp)<0){
ltr=wrd.substring(0,1);
ltr=ltr.toUpperCase();
wrd=ltr+wrd.substring(1,wr
}
txtl+=wrd+" ";
txt=txt.substring((pos+1),
}
ltr=txtl.substring(0,1);
ltr=ltr.toUpperCase();
txtl=ltr+txtl.substring(1,
document.acc_form.descript
}
function navNew(){
txt=document.acc_form.desc
txt=txt.toLowerCase();
txtl="";
punc=",.?!:;)'";
punc+='"';
while ((txt.length>0)&&(txt.inde
pos=txt.indexOf(" ");
wrd=txt.substring(0,pos);
wrdpre="";
if (punc.indexOf(wrd.substrin
wrdpre=wrd.substring(0,1);
wrd=wrd.substring(1,wrd.le
}
cmp=" "+wrd+" ";
for (var i=0;i<9;i++){
p=wrd.indexOf(punc.substri
if (p==wrd.length-1){
cmp=" "+wrd.substring(0,wrd.leng
i=9;
}
}
if (cmp.indexOf(cmp)<0){
ltr=wrd.substring(0,1);
ltr=ltr.toUpperCase();
wrd=ltr+wrd.substring(1,wr
}
txtl+=wrdpre+wrd+" ";
txt=txt.substring((pos+1),
}
ltr=txtl.substring(0,1);
ltr=ltr.toUpperCase();
txtl=ltr+txtl.substring(1,
document.acc_form.descript
}
// End -->
</script>
<FORM NAME="acc_form">
<CENTER>
<textarea NAME="description" ROWS=10></TEXTAREA>
<INPUT TYPE="button" NAME="html1" VALUE=" Submit " onClick="capsLc()">
</FORM>
</CENTER>
function toSentenceCase(str) {
var res = "";
var strEndSentence = ".!?";
var foundEndSentence = false;
for (i=0;i<str.length;i++) {
if (i == 0) {
res += str.charAt(i).toUpperCase( );
} else if (strEndSentence.indexOf(st r.charAt(i )) >= 0) {
res += str.charAt(i);
foundEndSentence = true;
} else if (foundEndSentence) {
if (str.charAt(i) == " ") {
res += " ";
} else {
res += str.charAt(i).toUpperCase( );
foundEndSentence = false;
}
} else if (str.charAt(i) == "i" && str.charAt(i-1) == " " && (str.charAt(i+1) == " " || i == str.length-1)) {
res += str.charAt(i).toUpperCase( );
} else {
res += str.charAt(i).toLowerCase( );
foundEndSentence = false;
}
}
return res;
}
alert (toSentenceCase("yesterday i WENT To the STORe. it's an AWESOME store! very COOL."));
var res = "";
var strEndSentence = ".!?";
var foundEndSentence = false;
for (i=0;i<str.length;i++) {
if (i == 0) {
res += str.charAt(i).toUpperCase(
} else if (strEndSentence.indexOf(st
res += str.charAt(i);
foundEndSentence = true;
} else if (foundEndSentence) {
if (str.charAt(i) == " ") {
res += " ";
} else {
res += str.charAt(i).toUpperCase(
foundEndSentence = false;
}
} else if (str.charAt(i) == "i" && str.charAt(i-1) == " " && (str.charAt(i+1) == " " || i == str.length-1)) {
res += str.charAt(i).toUpperCase(
} else {
res += str.charAt(i).toLowerCase(
foundEndSentence = false;
}
}
return res;
}
alert (toSentenceCase("yesterday
and here is the final fix
<head>
<script language="JavaScript">
<!-- Begin
function capsLc(){
if (navigator.appVersion.subs tring(0,1) =="2"){
navOld();
}
else navNew();
}
function navOld(){
txt=document.acc_form.desc ription.va lue+" ";
txt=txt.toLowerCase();
txtl="";
while ((txt.length>0)&&(txt.inde xOf(" ")>-1)){
pos=txt.indexOf(" ");
wrd=txt.substring(0,pos);
cmp=" "+wrd+" ";
if (tst.indexOf(cmp)<0){
ltr=wrd.substring(0,1);
ltr=ltr.toUpperCase();
wrd=ltr+wrd.substring(1,wr d.length);
}
txtl+=wrd+" ";
txt=txt.substring((pos+1), txt.length );
}
ltr=txtl.substring(0,1);
ltr=ltr.toUpperCase();
txtl=ltr+txtl.substring(1, txtl.lengt h-1);
document.acc_form.descript ion.value= txtl;
}
function navNew(){
txt=document.acc_form.desc ription.va lue+" ";
txt=txt.toLowerCase();
txtl="";
punc=",.?!:;)'";
punc+='"';
while ((txt.length>0)&&(txt.inde xOf(" ")>-1)){
pos=txt.indexOf(" ");
wrd=txt.substring(0,pos);
wrdpre="";
if (punc.indexOf(wrd.substrin g(0,1))>-1 ){
wrdpre=wrd.substring(0,1);
wrd=wrd.substring(1,wrd.le ngth);
}
cmp=" "+wrd+" ";
for (var i=0;i<9;i++){
p=wrd.indexOf(punc.substri ng(i,i+1)) ;
if (p==wrd.length-1){
cmp=" "+wrd.substring(0,wrd.leng th-1)+" ";
i=9;
}
}
if (cmp.indexOf(cmp)<0){
ltr=wrd.substring(0,1);
ltr=ltr.toUpperCase();
wrd=ltr+wrd.substring(1,wr d.length);
}
txtl+=wrdpre+wrd+" ";
txt=txt.substring((pos+1), txt.length );
}
ltr=txtl.substring(0,1);
ltr=ltr.toUpperCase();
txtl=ltr+txtl.substring(1, txtl.lengt h-1);
txtl=txtl.replace(/ i /g,' I ')
while (/[\.\!\?\;\"\'][\ ]*[a-z]/.test(txtl))
{
l=txtl.match(/[\.\!\?\;\"\ '][\ ]*[a-z]/)[0]
L=l.toUpperCase()
txtl=txtl.replace(l,L)
}
document.acc_form.descript ion.value= txtl;
}
// End -->
</script>
</head>
<body>
<form NAME="acc_form">
<div align="center"><center><p> <textarea NAME="description" ROWS="10"></textarea> <input
TYPE="button" NAME="html1" VALUE=" Submit " onClick="capsLc()"> </p>
</center></div>
</form>
</body>
</html>
<head>
<script language="JavaScript">
<!-- Begin
function capsLc(){
if (navigator.appVersion.subs
navOld();
}
else navNew();
}
function navOld(){
txt=document.acc_form.desc
txt=txt.toLowerCase();
txtl="";
while ((txt.length>0)&&(txt.inde
pos=txt.indexOf(" ");
wrd=txt.substring(0,pos);
cmp=" "+wrd+" ";
if (tst.indexOf(cmp)<0){
ltr=wrd.substring(0,1);
ltr=ltr.toUpperCase();
wrd=ltr+wrd.substring(1,wr
}
txtl+=wrd+" ";
txt=txt.substring((pos+1),
}
ltr=txtl.substring(0,1);
ltr=ltr.toUpperCase();
txtl=ltr+txtl.substring(1,
document.acc_form.descript
}
function navNew(){
txt=document.acc_form.desc
txt=txt.toLowerCase();
txtl="";
punc=",.?!:;)'";
punc+='"';
while ((txt.length>0)&&(txt.inde
pos=txt.indexOf(" ");
wrd=txt.substring(0,pos);
wrdpre="";
if (punc.indexOf(wrd.substrin
wrdpre=wrd.substring(0,1);
wrd=wrd.substring(1,wrd.le
}
cmp=" "+wrd+" ";
for (var i=0;i<9;i++){
p=wrd.indexOf(punc.substri
if (p==wrd.length-1){
cmp=" "+wrd.substring(0,wrd.leng
i=9;
}
}
if (cmp.indexOf(cmp)<0){
ltr=wrd.substring(0,1);
ltr=ltr.toUpperCase();
wrd=ltr+wrd.substring(1,wr
}
txtl+=wrdpre+wrd+" ";
txt=txt.substring((pos+1),
}
ltr=txtl.substring(0,1);
ltr=ltr.toUpperCase();
txtl=ltr+txtl.substring(1,
txtl=txtl.replace(/ i /g,' I ')
while (/[\.\!\?\;\"\'][\ ]*[a-z]/.test(txtl))
{
l=txtl.match(/[\.\!\?\;\"\
L=l.toUpperCase()
txtl=txtl.replace(l,L)
}
document.acc_form.descript
}
// End -->
</script>
</head>
<body>
<form NAME="acc_form">
<div align="center"><center><p>
TYPE="button" NAME="html1" VALUE=" Submit " onClick="capsLc()"> </p>
</center></div>
</form>
</body>
</html>
why does it need to be so long? ;)
my entry in the least amout of code category is
<head>
<script language="JavaScript">
function capsLc(){
txtl=document.acc_form.des cription.v alue
txtl=txtl.toLowerCase()
txtl=txtl.replace(/ i /g,' I ')
while (/[\.\!\?\;\"][\ ]*[a-z]/.test(txtl)){
l=txtl.match(/[\.\!\?\;\"] [\ ]*[a-z]/)[0]
L=l.toUpperCase()
txtl=txtl.replace(l,L)
}
document.acc_form.descript ion.value= txtl;
}
</script>
</head>
<body>
<form NAME="acc_form">
<div align="center"><center><p> <textarea NAME="description" ROWS="10"></textarea> <input
TYPE="button" NAME="html1" VALUE=" Submit " onClick="capsLc()"> </p>
</center></div>
</form>
</body>
</html>
<head>
<script language="JavaScript">
function capsLc(){
txtl=document.acc_form.des
txtl=txtl.toLowerCase()
txtl=txtl.replace(/ i /g,' I ')
while (/[\.\!\?\;\"][\ ]*[a-z]/.test(txtl)){
l=txtl.match(/[\.\!\?\;\"]
L=l.toUpperCase()
txtl=txtl.replace(l,L)
}
document.acc_form.descript
}
</script>
</head>
<body>
<form NAME="acc_form">
<div align="center"><center><p>
TYPE="button" NAME="html1" VALUE=" Submit " onClick="capsLc()"> </p>
</center></div>
</form>
</body>
</html>
forgot newlines if they are no indented, shld read
<script language="JavaScript">
function capsLc(){
txtl='document.acc_form.de scription. value
txtl=txtl.toLowerCase()
txtl=txtl.replace(/ i /g,' I ')
while (/[\n\r\.\!\?\;\"][\ ]*[a-z]/.test(txtl)){
l=txtl.match(/[\n\r\.\!\?\ ;\"][\ ]*[a-z]/)[0]
L=l.toUpperCase()
txtl=txtl.replace(l,L)
}
document.acc_form.descript ion.value= txtl;
}
</script>
<script language="JavaScript">
function capsLc(){
txtl='document.acc_form.de
txtl=txtl.toLowerCase()
txtl=txtl.replace(/ i /g,' I ')
while (/[\n\r\.\!\?\;\"][\ ]*[a-z]/.test(txtl)){
l=txtl.match(/[\n\r\.\!\?\
L=l.toUpperCase()
txtl=txtl.replace(l,L)
}
document.acc_form.descript
}
</script>
shld be txtl=document.acc_form.des cription.v alue ie remove '
Here my version:
<script language="JavaScript">
<!-- Begin
var letter = "abcdefghijklmopqrstuvwxyz ABCDEFGHIJ KLMNOPQRST UVWXYZ";
var newSent = ".!?";
function capsLc(theButton){
desc = theButton.form.description ;
descText = " "+desc.value;
descText = Capitalize(descText, 0);
for(var n=2;n<descText.length;n++) {
if(newSent.indexOf(descTex t.substr(n ,1))>-1){
descText = Capitalize(descText, n);
}
}
desc.value = descText.substr(1);
}
function Capitalize(theText, nextPos){
for(var i=nextPos;i<theText.length ;i++){
if(letter.indexOf(theText. substr(i,1 ))>-1){
theText = theText.substr(0,i)+
theText.substr(i,1).toUppe rCase()+
theText.substr(i+1).toLowe rCase();
break;
}
}
return theText;
}
// End -->
</script>
<FORM NAME="acc_form">
<CENTER>
<textarea NAME="description" ROWS=10>yesterday i WENT To the STORe. it's an AWESOME store! very COOL.</TEXTAREA>
<INPUT TYPE="button" NAME="html1" VALUE=" Submit " onClick="capsLc(this)">
</FORM>
</CENTER>
<script language="JavaScript">
<!-- Begin
var letter = "abcdefghijklmopqrstuvwxyz
var newSent = ".!?";
function capsLc(theButton){
desc = theButton.form.description
descText = " "+desc.value;
descText = Capitalize(descText, 0);
for(var n=2;n<descText.length;n++)
if(newSent.indexOf(descTex
descText = Capitalize(descText, n);
}
}
desc.value = descText.substr(1);
}
function Capitalize(theText, nextPos){
for(var i=nextPos;i<theText.length
if(letter.indexOf(theText.
theText = theText.substr(0,i)+
theText.substr(i,1).toUppe
theText.substr(i+1).toLowe
break;
}
}
return theText;
}
// End -->
</script>
<FORM NAME="acc_form">
<CENTER>
<textarea NAME="description" ROWS=10>yesterday i WENT To the STORe. it's an AWESOME store! very COOL.</TEXTAREA>
<INPUT TYPE="button" NAME="html1" VALUE=" Submit " onClick="capsLc(this)">
</FORM>
</CENTER>
Small Note: my version does work WITHOUT RegExp!
Smaller note: mine does too
try this
function navNew(){
txt=document.acc_form.desc ription.va lue+" ";
txt=txt.toLowerCase();
txt1="";
punc=",.?!:;)";
punc+='"';
puncFound = true;
for (i=0; i < txt.length; i++) {
curChar = txt.substring(i, i+1);
if (puncFound && (curChar != " ") && (punc.indexOf(curChar) == -1)) {
puncFound = false;
curChar = curChar.toUpperCase();
} else if (punc.indexOf(curChar) > 0) {
puncFound = true;
} else if (curChar == 'i') {
if (i == 0 || ((punc + " ").indexOf(txt.substring(i - 1, i)) > 0 && (punc + " ").indexOf(txt.substring(i +1, i+2)) > 0)) {
curChar = curChar.toUpperCase();
}
}
txt1 = txt1 + curChar;
}
document.acc_form.descript ion.value= txt1;
}
function navNew(){
txt=document.acc_form.desc
txt=txt.toLowerCase();
txt1="";
punc=",.?!:;)";
punc+='"';
puncFound = true;
for (i=0; i < txt.length; i++) {
curChar = txt.substring(i, i+1);
if (puncFound && (curChar != " ") && (punc.indexOf(curChar) == -1)) {
puncFound = false;
curChar = curChar.toUpperCase();
} else if (punc.indexOf(curChar) > 0) {
puncFound = true;
} else if (curChar == 'i') {
if (i == 0 || ((punc + " ").indexOf(txt.substring(i
curChar = curChar.toUpperCase();
}
}
txt1 = txt1 + curChar;
}
document.acc_form.descript
}
@bobbit31: check yours with initial blanks.
@lserrano: My failed for uppercase I
Here is the "I" correction working also when not separated on both sides by blank.
<script language="JavaScript">
<!-- Begin
var letter = "abcdefghijklmopqrstuvwxyz ABCDEFGHIJ KLMNOPQRST UVWXYZ";
var newSent = ".!?";
function capsLc(theButton){
desc = theButton.form.description ;
descText = " "+desc.value;
descText = Capitalize(descText, 0);
for(var n=2;n<descText.length;n++) {
if(newSent.indexOf(descTex t.substr(n ,1))>-1){
descText = Capitalize(descText, n);
}
}
descText = iAm(descText);
desc.value = descText.substr(1);
}
function Capitalize(theText, nextPos){
for(var i=nextPos;i<theText.length ;i++){
if(letter.indexOf(theText. substr(i,1 ))>-1){
theText = theText.substr(0,i)+
theText.substr(i,1).toUppe rCase()+
theText.substr(i+1).toLowe rCase();
break;
}
}
return theText;
}
function iAm(theText){
for(var i=0;i<theText.length;i++){
if(letter.indexOf(theText. substr(i,1 ))<0 &&
theText.substr(i+1,1)=="i" &&
letter.indexOf(theText.sub str(i+2,1) )<0){
theText = theText.substr(0,i+1)+"I"+ theText.su bstr(i+2);
}
}
return theText;
}
// End -->
</script>
<FORM NAME="acc_form">
<CENTER>
<textarea NAME="description" ROWS=10> aaa yesterday i WENT To the STORe. it's an AWESOME store! very COOL.</TEXTAREA>
<INPUT TYPE="button" NAME="html1" VALUE=" Submit " onClick="capsLc(this)">
</FORM>
</CENTER>
@lserrano: My failed for uppercase I
Here is the "I" correction working also when not separated on both sides by blank.
<script language="JavaScript">
<!-- Begin
var letter = "abcdefghijklmopqrstuvwxyz
var newSent = ".!?";
function capsLc(theButton){
desc = theButton.form.description
descText = " "+desc.value;
descText = Capitalize(descText, 0);
for(var n=2;n<descText.length;n++)
if(newSent.indexOf(descTex
descText = Capitalize(descText, n);
}
}
descText = iAm(descText);
desc.value = descText.substr(1);
}
function Capitalize(theText, nextPos){
for(var i=nextPos;i<theText.length
if(letter.indexOf(theText.
theText = theText.substr(0,i)+
theText.substr(i,1).toUppe
theText.substr(i+1).toLowe
break;
}
}
return theText;
}
function iAm(theText){
for(var i=0;i<theText.length;i++){
if(letter.indexOf(theText.
theText.substr(i+1,1)=="i"
letter.indexOf(theText.sub
theText = theText.substr(0,i+1)+"I"+
}
}
return theText;
}
// End -->
</script>
<FORM NAME="acc_form">
<CENTER>
<textarea NAME="description" ROWS=10> aaa yesterday i WENT To the STORe. it's an AWESOME store! very COOL.</TEXTAREA>
<INPUT TYPE="button" NAME="html1" VALUE=" Submit " onClick="capsLc(this)">
</FORM>
</CENTER>
here is my version:
==================
<div id=myText>"yesterday i WENT To the STORe. it's an AWESOME store! very COOL."</div>
"Yesterday I went to the store. It's an awesome store! Very cool."<br>
<script>
function runit()
{
var objMyText=document.getElem entById("m yText");
objMyText.innerHTML=objMyT ext.innerH TML.toLowe rCase().re place(/^.( .){1}|i|\. (.)|\! (.)/g, function(p1,p2){return p1.toUpperCase()});
}
</script>
<button onclick=runit()>runit</but ton>
==================
<div id=myText>"yesterday i WENT To the STORe. it's an AWESOME store! very COOL."</div>
"Yesterday I went to the store. It's an awesome store! Very cool."<br>
<script>
function runit()
{
var objMyText=document.getElem
objMyText.innerHTML=objMyT
}
</script>
<button onclick=runit()>runit</but
of course you don't need a quotation marks ;)
==========
<div id=myText>yesterday i WENT To the STORe. it's an AWESOME store! very COOL.</div>
Yesterday I went to the store. It's an awesome store! Very cool.<br>
<script>
function runit()
{
var objMyText=document.getElem entById("m yText");
objMyText.innerHTML=objMyT ext.innerH TML.toLowe rCase().re place(/^(. ){1}|i|\. (.)|\! (.)/g, function(p1,p2){return p1.toUpperCase()});
}
</script>
<button onclick=runit()>runit</but ton>
==========
<div id=myText>yesterday i WENT To the STORe. it's an AWESOME store! very COOL.</div>
Yesterday I went to the store. It's an awesome store! Very cool.<br>
<script>
function runit()
{
var objMyText=document.getElem
objMyText.innerHTML=objMyT
}
</script>
<button onclick=runit()>runit</but
re: "Small Note: my version does work WITHOUT RegExp!"
so what!
so what!
So what?
You need no version checking like this:
if (navigator.appVersion.subs tring(0,1) =="2"){
navOld();
....
You need no version checking like this:
if (navigator.appVersion.subs
navOld();
....
re: (navigator.appVersion.subs tring(0,1) =="2")
is that a joke? So what else do you remove from the JS tool box if you check back to "2", :)
is that a joke? So what else do you remove from the JS tool box if you check back to "2", :)
ASKER
@zvonko: Is it possible to also check for multiple spaces between words and reduce to just 1 space? So if user enters "Yesterday I went to the store." Script would change to "Yesterday I went to the store."
Yes, that is easy.
But please state how important is for you to avoid RegExp.
Because RegExp make life much more easier.
But please state how important is for you to avoid RegExp.
Because RegExp make life much more easier.
yeah, RegExp is power!
<textarea id=myText style=width:600px;height:2 00px>
yesterday i WENT To the STORe. it's an AWESOME store! very COOL.
</textarea>
<script>
function runit()
{
var objMyText=document.getElem entById("m yText");
objMyText.innerHTML=objMyT ext.innerH TML.toLowe rCase().re place(/ /g," ").replace(/^(.){1}|i|\. (.)|\! (.)/g, function(p1,p2){return p1.toUpperCase()});
}
</script>
<br>
<button onclick=runit()>runit</but ton>
<textarea id=myText style=width:600px;height:2
yesterday i WENT To the STORe. it's an AWESOME store! very COOL.
</textarea>
<script>
function runit()
{
var objMyText=document.getElem
objMyText.innerHTML=objMyT
}
</script>
<br>
<button onclick=runit()>runit</but
Here the NON regexp solution :)
<script language="JavaScript">
<!-- Begin
var letter = "abcdefghijklmopqrstuvwxyz ABCDEFGHIJ KLMNOPQRST UVWXYZ";
var newSent = ".!?";
function capsLc(theButton){
desc = theButton.form.description ;
descText = " "+desc.value;
descText = Capitalize(descText, 0);
for(var n=2;n<descText.length;n++) {
if(newSent.indexOf(descTex t.substr(n ,1))>-1){
descText = Capitalize(descText, n);
}
}
descText = iAm(fullTrim(descText));
desc.value = descText.substr(1);
}
function Capitalize(theText, nextPos){
for(var i=nextPos;i<theText.length ;i++){
if(letter.indexOf(theText. substr(i,1 ))>-1){
theText = theText.substr(0,i)+
theText.substr(i,1).toUppe rCase()+
theText.substr(i+1).toLowe rCase();
break;
}
}
return theText;
}
function iAm(theText){
for(var i=0;i<theText.length;i++){
if(letter.indexOf(theText. substr(i,1 ))<0 &&
theText.substr(i+1,1)=="i" &&
letter.indexOf(theText.sub str(i+2,1) )<0){
theText = theText.substr(0,i+1)+"I"+ theText.su bstr(i+2);
}
}
return theText;
}
function fullTrim(theText){
for(var i=0;i<theText.length;i++){
while(theText.substr(i,2)= =" "){
theText = theText.substr(0,i)+theTex t.substr(i +1);
}
}
return theText;
}
// End -->
</script>
<FORM NAME="acc_form">
<CENTER>
<textarea NAME="description" ROWS=10> yesterday i WENT To the STORe. it's an AWESOME store! very COOL.</TEXTAREA>
<INPUT TYPE="button" NAME="html1" VALUE=" Submit " onClick="capsLc(this)">
</FORM>
</CENTER>
<script language="JavaScript">
<!-- Begin
var letter = "abcdefghijklmopqrstuvwxyz
var newSent = ".!?";
function capsLc(theButton){
desc = theButton.form.description
descText = " "+desc.value;
descText = Capitalize(descText, 0);
for(var n=2;n<descText.length;n++)
if(newSent.indexOf(descTex
descText = Capitalize(descText, n);
}
}
descText = iAm(fullTrim(descText));
desc.value = descText.substr(1);
}
function Capitalize(theText, nextPos){
for(var i=nextPos;i<theText.length
if(letter.indexOf(theText.
theText = theText.substr(0,i)+
theText.substr(i,1).toUppe
theText.substr(i+1).toLowe
break;
}
}
return theText;
}
function iAm(theText){
for(var i=0;i<theText.length;i++){
if(letter.indexOf(theText.
theText.substr(i+1,1)=="i"
letter.indexOf(theText.sub
theText = theText.substr(0,i+1)+"I"+
}
}
return theText;
}
function fullTrim(theText){
for(var i=0;i<theText.length;i++){
while(theText.substr(i,2)=
theText = theText.substr(0,i)+theTex
}
}
return theText;
}
// End -->
</script>
<FORM NAME="acc_form">
<CENTER>
<textarea NAME="description" ROWS=10> yesterday i WENT To the STORe. it's an AWESOME store! very COOL.</TEXTAREA>
<INPUT TYPE="button" NAME="html1" VALUE=" Submit " onClick="capsLc(this)">
</FORM>
</CENTER>
@devic: you have also the leading blank problem.
sorry :)
===============
<textarea id=myText style=width:600px;height:2 00px>
yesterday i WENT To the STORe. it's an AWESOME store! very COOL.
</textarea>
<script>
function runit()
{
var objMyText=document.getElem entById("m yText");
objMyText.innerHTML=objMyT ext.innerH TML.toLowe rCase().re place(/[ ]{1,}/g," ").replace(/^(.){1}|i|\. (.)|\! (.)/g, function(p1,p2){return p1.toUpperCase()});
}
</script>
<br>
<button onclick=runit()>runit</but ton>
===============
<textarea id=myText style=width:600px;height:2
yesterday i WENT To the STORe. it's an AWESOME store! very COOL.
</textarea>
<script>
function runit()
{
var objMyText=document.getElem
objMyText.innerHTML=objMyT
}
</script>
<br>
<button onclick=runit()>runit</but
Still not working.
Put a blank before yesterday
First single blank should not disappear and next Character should be Capitalized.
Put a blank before yesterday
First single blank should not disappear and next Character should be Capitalized.
ach so, i did not test with blank at the beginn of string.
thanks Zvonko ;)
==================
<textarea id=myText style=width:600px;height:2 00px>
yesterday i WENT To the STORe. it's an AWESOME store! very COOL.
</textarea>
<script>
function runit()
{
var objMyText=document.getElem entById("m yText");
objMyText.innerHTML=objMyT ext.innerH TML.toLowe rCase().re place(/[ ]{1,}/g," ").replace(/^ ?(.){1}|i|\. (.)|\! (.)/g, function(p1,p2){return p1.toUpperCase()});
}
</script>
<br>
<button onclick=runit()>runit</but ton>
thanks Zvonko ;)
==================
<textarea id=myText style=width:600px;height:2
yesterday i WENT To the STORe. it's an AWESOME store! very COOL.
</textarea>
<script>
function runit()
{
var objMyText=document.getElem
objMyText.innerHTML=objMyT
}
</script>
<br>
<button onclick=runit()>runit</but
Nearly perfect: you remove single leading blank.
But I think that is normal in any written English text.
But I think that is normal in any written English text.
By the way: your replace() RegExp lambda function call limits your method to JavaScript1.3
yes Zvonko, we spoke already about this, but i like lambda expression ;)
BTW JavaScript Version Statistic:
1.3 98.87%
1.0 0.57%
1.2 0.55%
other 0.02%
so for 98.87% is ok ;)
1.3 98.87%
1.0 0.57%
1.2 0.55%
other 0.02%
so for 98.87% is ok ;)
this implements a dictionary of proper names and 2 spaces beetween sentences
eg input
" hi jOhn and mary! hOw are i am cINdy.
I am from THe USA ARE yoU from THe UK?"
ouput
" Hi John and Mary! How are I am Cindy.
I am from the USA are you from the UK?"
<script language="JavaScript">
capString='Dave,John,Mary, Randy,Cind y,USA,UK,C anada,Fran ce'
capArray=capString.split(' ,')
function capsLc(txt){
txt=txt.toLowerCase()
txt=txt.replace(/ i([^a-z])/gi,' I'+'$1')
while (/[\n\r\.\!\?\;\"][\ ]*[a-z]/.test(txt)){
l=txt.match(/[\n\r\.\!\?\; \"][\ ]*[a-z]/)[0]
L=l.toUpperCase()
txt=txt.replace(l,L)
}
txt=txt.replace(/((\w) +(\w))/g,'$2'+' '+'$3')
txt.replace
words=txt.match(/[a-z]+/gi )
for (i=0;i<words.length;i++)
for (j=0;j<capArray.length;j++ ){
if (words[i].toLowerCase()==c apArray[j] .toLowerCa se())
txt=txt.replace(words[i],c apArray[j] )
}
return txt
}
txt='" hi jOhn and mary! hOw are i am cINdy.'+'\n'+' I am from THe USA ARE yoU from THe UK?"'
alert(txt)
alert(capsLc(txt))
</script>
eg input
" hi jOhn and mary! hOw are i am cINdy.
I am from THe USA ARE yoU from THe UK?"
ouput
" Hi John and Mary! How are I am Cindy.
I am from the USA are you from the UK?"
<script language="JavaScript">
capString='Dave,John,Mary,
capArray=capString.split('
function capsLc(txt){
txt=txt.toLowerCase()
txt=txt.replace(/ i([^a-z])/gi,' I'+'$1')
while (/[\n\r\.\!\?\;\"][\ ]*[a-z]/.test(txt)){
l=txt.match(/[\n\r\.\!\?\;
L=l.toUpperCase()
txt=txt.replace(l,L)
}
txt=txt.replace(/((\w) +(\w))/g,'$2'+' '+'$3')
txt.replace
words=txt.match(/[a-z]+/gi
for (i=0;i<words.length;i++)
for (j=0;j<capArray.length;j++
if (words[i].toLowerCase()==c
txt=txt.replace(words[i],c
}
return txt
}
txt='" hi jOhn and mary! hOw are i am cINdy.'+'\n'+' I am from THe USA ARE yoU from THe UK?"'
alert(txt)
alert(capsLc(txt))
</script>
this argument from Zvonko is a nonesense (ie Ver 1.3 =98.87%)
Oh so you do not recommend using regex? see http:Q_20893061.html
perhaps you should give the points back :)
?
ASKER
@zvonko: One problem I found with your solution is when I type the word "opening" it changes to "openIng."
<textarea id=myText style=width:600px;height:2 00px>
yesterday i WENT To the opening STORe. it's an AWESOME store! very COOL.
</textarea>
<script>
function runit()
{
var objMyText=document.getElem entById("m yText");
objMyText.innerHTML=objMyT ext.innerH TML.toLowe rCase().re place(/[ ]{1,}/g," ").replace(/^ ?(.){1}| (i) |\. (.)|\! (.)/g, function(p1,p2){return p1.toUpperCase()});
}
</script>
<br>
<button onclick=runit()>runit</but ton>
yesterday i WENT To the opening STORe. it's an AWESOME store! very COOL.
</textarea>
<script>
function runit()
{
var objMyText=document.getElem
objMyText.innerHTML=objMyT
}
</script>
<br>
<button onclick=runit()>runit</but
Last version, it has a proper name dictionary and a spell check dictionary. The code needs some tuneing but the basic idea is there (must be bored tonight)
"tEH comPtr taht i got FroM cINDY in thE UsA, iS bRoKE!
wHy? oH DEar, Oh dEAR"
becomes
"The computer that I got from Cindy in the USA, is broke!
Why? Oh dear, oh dear"
<head>
<script language="JavaScript">
capString='Dave,John,Mary, Randy,Cind y,USA,UK,C anada,Fran ce'
capArray=capString.split(' ,')
spellString="the,teh,hte;t hat,taht;c omputer,co mptr,compu tr"
spellArray=spellString.spl it(';')
function capsLc(txt){
txt=txt.toLowerCase()
txt=txt.replace(/((\w[^ ]) {2,}(\w))/g,'$2'+' '+'$3')
txt=txt.replace(/ i([^a-z])/gi,' I'+'$1')
words=txt.match(/[a-z]+/gi )
for (i=0;i<words.length;i++){
for (j=0;j<capArray.length;j++ )
if (words[i].toLowerCase()==c apArray[j] .toLowerCa se())
txt=txt.replace(words[i],c apArray[j] )
for (j=0;j<spellArray.length;j ++){
reg=new RegExp(words[i].toLowerCas e(),'gi')
if ( reg.test(spellArray[j]) )
txt=txt.replace(words[i],s pellArray[ j].split(' ,')[0])
}
}
while (/[\n\r\.\!\?\;\"][\ ]*[a-z]/.test(txt)){
l=txt.match(/[\n\r\.\!\?\; \"][\ ]*[a-z]/)[0]
L=l.toUpperCase()
txt=txt.replace(l,L)
}
return txt
}
</script>
</head>
<body>
<p><textarea name="t1" rows="20" cols="40"></textarea></p>
<p>sample text:<br>
"tEH comPtr taht i got FroM cINDY in thE UsA, iS bRoKE!<br>
wHy? oH DEar, Oh dEAR" </p>
<p><input type="button" value="edit" onclick=" t1.value=capsLc(t1.value)" ></p>
</body>
</html>
"tEH comPtr taht i got FroM cINDY in thE UsA, iS bRoKE!
wHy? oH DEar, Oh dEAR"
becomes
"The computer that I got from Cindy in the USA, is broke!
Why? Oh dear, oh dear"
<head>
<script language="JavaScript">
capString='Dave,John,Mary,
capArray=capString.split('
spellString="the,teh,hte;t
spellArray=spellString.spl
function capsLc(txt){
txt=txt.toLowerCase()
txt=txt.replace(/((\w[^ ]) {2,}(\w))/g,'$2'+' '+'$3')
txt=txt.replace(/ i([^a-z])/gi,' I'+'$1')
words=txt.match(/[a-z]+/gi
for (i=0;i<words.length;i++){
for (j=0;j<capArray.length;j++
if (words[i].toLowerCase()==c
txt=txt.replace(words[i],c
for (j=0;j<spellArray.length;j
reg=new RegExp(words[i].toLowerCas
if ( reg.test(spellArray[j]) )
txt=txt.replace(words[i],s
}
}
while (/[\n\r\.\!\?\;\"][\ ]*[a-z]/.test(txt)){
l=txt.match(/[\n\r\.\!\?\;
L=l.toUpperCase()
txt=txt.replace(l,L)
}
return txt
}
</script>
</head>
<body>
<p><textarea name="t1" rows="20" cols="40"></textarea></p>
<p>sample text:<br>
"tEH comPtr taht i got FroM cINDY in thE UsA, iS bRoKE!<br>
wHy? oH DEar, Oh dEAR" </p>
<p><input type="button" value="edit" onclick=" t1.value=capsLc(t1.value)"
</body>
</html>
Sorry, my alphabet was not complete.
Take this:
var letter = "abcdefghijklmnopqrstuvwxy zABCDEFGHI JKLMNOPQRS TUVWXYZ";
Take this:
var letter = "abcdefghijklmnopqrstuvwxy
var letter = "abcdefghijklmnopqrstuvwxy zABCDEFGHI JKLMNOPQRS TUVWXYZÀÁ ÃÄÅÆÇÈÉÊËÌ ÍÎÏÐÑÒÓÔÕÖ ×ØÙÚÛÜÝÞßà áâãäåæçèéê ëìíîïðñòóô õö÷øùúûüýþ ÿ";
ASKER
@GwynforWeb: Your solution works quite well, except from "tEH comPtr taht i got FroM cINDY in thE UsA, iS bRoKE! wHy? oH DEar, Oh dEAR" I get "the computer that I got from Cindy in the USA, is broke! Why? Oh dear, oh dear". Notice the first word is "the" but should be "The"
ASKER
BTW, can you also ensure that there is 1 space after the end of each sentence and bfore the beginning of the next sentence?
i.e.,
"Good stuff. Great!" should be changed to "Good stuff. Great!"
And, some words like eBooks and eCourse are okay, so can I have a list of these which are acceptable and should NOT be changed to lowercase?
i.e.,
"Good stuff. Great!" should be changed to "Good stuff. Great!"
And, some words like eBooks and eCourse are okay, so can I have a list of these which are acceptable and should NOT be changed to lowercase?
ASKER
BTW, points to be increased to 800 as soon as I can figure out how to increase them. ;-)
lserrano,
Heck, the 'the' problem only happens sometimes, i missed the subcase. Try this, (there is only 1 space between sentences if you check withe the cursor)
<head>
<script language="JavaScript">
capString='Dave,John,Mary, Randy,Cind y,USA,UK,C anada,Fran ce,eBook,e Course'
capArray=capString.split(' ,')
spellString="the,teh,hte;t hat,taht;c omputer,co mptr,compu tr"
spellArray=spellString.spl it(';')
function capsLc(txt){
txt='"'+txt.toLowerCase()
txt=txt.replace(/([\.\!\?\ ;\"\:\,])[ \ ]*([a-z])/g,'$1'+' '+'$2')
txt=txt.replace(/ i([^a-z])/gi,' I'+'$1')
words=txt.match(/[a-z]+/gi )
for (i=0;i<words.length;i++){
for (j=0;j<capArray.length;j++ )
if (words[i].toLowerCase()==c apArray[j] .toLowerCa se())
txt=txt.replace(words[i],c apArray[j] )
for (j=0;j<spellArray.length;j ++){
reg=new RegExp(words[i].toLowerCas e(),'gi')
if ( reg.test(spellArray[j]) )
txt=txt.replace(words[i],s pellArray[ j].split(' ,')[0])
}
}
while (/[\n\r\.\!\?\;\"\:\,][\ ]*[a-z]/.test(txt)){
l=txt.match(/[\n\r\.\!\?\; \"\:\,][\ ]*[a-z]/)[0]
L=l.toUpperCase()
txt=txt.replace(l,L)
}
return txt.replace(/^" /,'')
}
</script>
<title></title>
</head>
<body>
<p><textarea name="t1" rows="20" cols="40"></textarea></p>
<p>sample text:<br>
"tEH comPtr taht i got FroM cINDY in thE UsA iS bRoKE! I am DOIng an ECOurse from the
EBook. <br>
wHy? oH DEar, Oh dEAR.<br> Good stuff.Great!"</p>
<p><input type="button" value="edit" onclick=" t1.value=capsLc(t1.value)" ></p>
</body>
</html>
Heck, the 'the' problem only happens sometimes, i missed the subcase. Try this, (there is only 1 space between sentences if you check withe the cursor)
<head>
<script language="JavaScript">
capString='Dave,John,Mary,
capArray=capString.split('
spellString="the,teh,hte;t
spellArray=spellString.spl
function capsLc(txt){
txt='"'+txt.toLowerCase()
txt=txt.replace(/([\.\!\?\
txt=txt.replace(/ i([^a-z])/gi,' I'+'$1')
words=txt.match(/[a-z]+/gi
for (i=0;i<words.length;i++){
for (j=0;j<capArray.length;j++
if (words[i].toLowerCase()==c
txt=txt.replace(words[i],c
for (j=0;j<spellArray.length;j
reg=new RegExp(words[i].toLowerCas
if ( reg.test(spellArray[j]) )
txt=txt.replace(words[i],s
}
}
while (/[\n\r\.\!\?\;\"\:\,][\ ]*[a-z]/.test(txt)){
l=txt.match(/[\n\r\.\!\?\;
L=l.toUpperCase()
txt=txt.replace(l,L)
}
return txt.replace(/^" /,'')
}
</script>
<title></title>
</head>
<body>
<p><textarea name="t1" rows="20" cols="40"></textarea></p>
<p>sample text:<br>
"tEH comPtr taht i got FroM cINDY in thE UsA iS bRoKE! I am DOIng an ECOurse from the
EBook. <br>
wHy? oH DEar, Oh dEAR.<br> Good stuff.Great!"</p>
<p><input type="button" value="edit" onclick=" t1.value=capsLc(t1.value)"
</body>
</html>
ASKER
Just one strange thing...
When I include ANY word in spellString which contains the letter "i" the script does funny translations.
Try using my spellString:
spellString="the,teh,hte;t hat,taht;r ecieve,rec eive;websi te,web site;entrepeneur,entrepren eur;contin ous,contin uous;homeb ased,home- based;home based,home-based;managerme nt,managem ent;porspe cts,prospe cts;strate gise,strat egize"
Also, can you allow for words like "home-based" and "web site" in spellString please.
When I include ANY word in spellString which contains the letter "i" the script does funny translations.
Try using my spellString:
spellString="the,teh,hte;t
Also, can you allow for words like "home-based" and "web site" in spellString please.
Iserrano,
Did you try my code...
Did you try my code...
ASKER
Can someone address my last comments? I'll then accept your answer as my preferred solution.
Here my RegExp version:
<head>
<title>Capitalize</title>
<script>
capArray= 'I,Dave,John,Mary,Randy,Ci
spellArray=("the,teh,hte;t
"entrepeneur,entrepreneur;
"homebased,home-based;home
"prospects,porspects;strat
function capsLc(theButton){
desc = theButton.form.description
descText = "."+desc.value.toLowerCase
descText = descText.replace(/\ +/g," ");
for(i=0;i<spellArray.lengt
spellWord = spellArray[i].split(',');
for(j=1;j<spellWord.length
descText = descText.replace(new RegExp("\\b"+spellWord[j]+
}
}
descText = descText.replace(/[\.\!\?]
for(i=0;i<capArray.length;
descText = descText.replace(new RegExp("\\b"+capArray[i]+"
}
desc.value = descText.substr(1);
}
</script>
</head>
<body>
<FORM NAME="acc_form">
<CENTER>
<textarea NAME="description" ROWS=10>tEH comPtr taht i got FroM cINDY in thE UsA, iS bRoKE! wHy? oH DEar, Oh dEAR!</TEXTAREA>
<INPUT TYPE="button" NAME="html1" VALUE=" Submit " onClick="capsLc(this)">
</FORM>
</CENTER>
</body>
</html>
I have addresdsed your last request.
Now are all spell correction requests done first and then is the word array applied.
Now is "I" aslo a word of that capsArray.
Now are all spell correction requests done first and then is the word array applied.
Now is "I" aslo a word of that capsArray.
ASKER
Strange, but although you have recieve,receive; in your spellArray, the mis-spelled word doesn't get changed. Also, the word "website" is not changed to "web site" and "home based" is not changed to "home-based"
Thanks for all your help.
BTW, how do I increase these points to 800?
Thanks for all your help.
BTW, how do I increase these points to 800?
By offering a second question with three hundred points and reference to this question.
And the syntax of the spellArray list is this:
spellArray = "toWord0, fromWord1, fromWord2; ...";
That does say: if in text are the words fromWord1 or fromWord2 found, then are all occurances of those words changed to toWord0.
And the syntax of the spellArray list is this:
spellArray = "toWord0, fromWord1, fromWord2; ...";
That does say: if in text are the words fromWord1 or fromWord2 found, then are all occurances of those words changed to toWord0.
ASKER
Thanks Zvonko. What I was aksing is how do I increase the points from 500 to 800? Right now when I award these points to you, you'll only get 500, but I want to give you 800. I can't see where to change the points.
Also, one last thing, when a user enters quotation marks or exclamation points, can you remove quotation marks and replace exclamation points with dots?
i.e.,
Entered:
This product will "blow your socks off" or it's completely free!
Change to:
This product will blow your socks off or it's completely free.
Also, one last thing, when a user enters quotation marks or exclamation points, can you remove quotation marks and replace exclamation points with dots?
i.e.,
Entered:
This product will "blow your socks off" or it's completely free!
Change to:
This product will blow your socks off or it's completely free.
ASKER
BTW, does this script work with MSIE and Netscape?
Here the version with your last requirements.
<head>
<title>Capitalize</title>
<script>
capArray= 'I,Dave,John,Mary,Randy,Ci ndy,USA,UK ,Canada,Fr ance,eBook ,eCourse'. split(',') ;
spellArray=("the,teh,hte;t hat,taht;r ecieve,rec eive;websi te,web site;"+
"entrepeneur,entrepreneur; continous, continuous ;"+
"homebased,home-based;home based,home-based;managerme nt,managem ent;"+
"prospects,porspects;strat egise,stra tegize;com puter,comp tr,computr ").split(' ;');
function capsLc(theButton){
desc = theButton.form.description ;
descText = "."+desc.value.toLowerCase ().replace (/\"/g,"") .replace(/ \!/g,'.');
descText = descText.replace(/\ +/g," ");
for(i=0;i<spellArray.lengt h;i++){
spellWord = spellArray[i].split(',');
for(j=1;j<spellWord.length ;j++){
descText = descText.replace(new RegExp("\\b"+spellWord[j]+ "\\b", "gi"), spellWord[0]);
}
}
descText = descText.replace(/[\.\!\?] \s*([a-z]) /g, function (p1,p2){return p1.toUpperCase()});
for(i=0;i<capArray.length; i++){
descText = descText.replace(new RegExp("\\b"+capArray[i]+" \\b", "gi"), capArray[i]);
}
desc.value = descText.substr(1);
}
</script>
</head>
<body>
<FORM NAME="acc_form">
<CENTER>
<textarea NAME="description" ROWS=10>tEH comPtr taht i got FroM cINDY in thE UsA, iS bRoKE! wHy? oH DEar, Oh dEAR!
This product will "blow your socks off" or it's completely free!
</TEXTAREA>
<INPUT TYPE="button" NAME="html1" VALUE=" Submit " onClick="capsLc(this)">
</FORM>
</CENTER>
</body>
</html>
And I need no eight hundred points. This five are enough.
<head>
<title>Capitalize</title>
<script>
capArray= 'I,Dave,John,Mary,Randy,Ci
spellArray=("the,teh,hte;t
"entrepeneur,entrepreneur;
"homebased,home-based;home
"prospects,porspects;strat
function capsLc(theButton){
desc = theButton.form.description
descText = "."+desc.value.toLowerCase
descText = descText.replace(/\ +/g," ");
for(i=0;i<spellArray.lengt
spellWord = spellArray[i].split(',');
for(j=1;j<spellWord.length
descText = descText.replace(new RegExp("\\b"+spellWord[j]+
}
}
descText = descText.replace(/[\.\!\?]
for(i=0;i<capArray.length;
descText = descText.replace(new RegExp("\\b"+capArray[i]+"
}
desc.value = descText.substr(1);
}
</script>
</head>
<body>
<FORM NAME="acc_form">
<CENTER>
<textarea NAME="description" ROWS=10>tEH comPtr taht i got FroM cINDY in thE UsA, iS bRoKE! wHy? oH DEar, Oh dEAR!
This product will "blow your socks off" or it's completely free!
</TEXTAREA>
<INPUT TYPE="button" NAME="html1" VALUE=" Submit " onClick="capsLc(this)">
</FORM>
</CENTER>
</body>
</html>
And I need no eight hundred points. This five are enough.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Zvonko. ;-)
You are welcome.
txtl=ltr+txtl.substring(1,
txtl=txtl.replace(/ i /g,' I ')
document.acc_form.descript
}