• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do I remove quotes from around string a user inputted in text box?

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the user enters quotes around a string they are entering, how is it that I can strip the quotes off and then reassign the string to the text box. Please show some sample code if you can?
Thank you.
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This should get you started:

<html>
<head>
<script language="javascript">
function stripThoseQuotes(chr)
{
if(chr.indexOf('"') != -1)
{
document.frmNoQuotes.noquotes.value = chr.replace('"','');
}
}
</script>
<body>
<form name="frmNoQuotes">
<input type="text" name="noquotes" onkeypress="stripThoseQuotes(this.value);">
</form>
</body>
</html>
You could trigger this function from any event, such as an onsubmit of the form, which would be more effective.
hope that helps.
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cool that should work... are you sure that it will see ('"') corectly? you dont need to do ("/"")?
I love the way you name your functions
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the function replace is used with regular expressions,isn't it?
the function should be more basic like:
function removeCharacter(str){
for(var i = 0;i < str.length;++){
str[i] = (str[i] == '\"' ? "" : str[i])
}
}
 
Moined Mogul
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I take a string that is selected from a drop down menu and check to see if it has double quotes around it, if it does, then remove the quotes and submit the new string without quotes instead of the one selected?
Please help....urgent!!!
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
isnt there a regular expression that could be used to remove quotes from a sting? i have this same problem, but the strings that i'm working with are very long, and i need to remove the quotes rapidly
thanks
centipede
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<script>
function theReplace(theStr) {
var regStr = new RegExp('"', "gi")
return theStr.replace(regStr, "")
}
hm = theReplace('move"""""""move"move');
alert(hm)
</script>
 
Police line, do not cross. Well, this tiny ad can go through:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic