wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes How do I remove quotes from around string a user inputted in text box? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How do I remove quotes from around string a user inputted in text box?" Watch "How do I remove quotes from around string a user inputted in text box?" New topic
Author

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

Moined Mogul
Ranch Hand

Joined: Jul 11, 2001
Posts: 33
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

Joined: Jun 27, 2001
Posts: 171
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

Joined: Oct 21, 2000
Posts: 4347
    
    2

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


SCJP
Visit my download page
xavier romea
Ranch Hand

Joined: Jun 28, 2001
Posts: 37
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

Joined: Jul 11, 2001
Posts: 33
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

Joined: Aug 16, 2003
Posts: 1
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
<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
 
subject: How do I remove quotes from around string a user inputted in text box?