File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Moined Mogul
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Brian Glodde
Ranch Hand
Posts: 171
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Randall Twede
Ranch Hand
Posts: 4353
2
Java
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
xavier romea
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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!!!
 
justov pinkton
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • 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>
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic