Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Single quote in text box 2

Status
Not open for further replies.

petermeachem

Programmer
Aug 26, 2000
2,270
0
0
GB
I can't work out how to handle quotes in mylastname here. This must be easy, but I just can't fix it.

Response.Write " <td width='257' height='30'><input type='text' name='txtLastName' size='20' maxlength='20' value = '" & mylastname & "'></td>
 
Replace it with 2 of them

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
Doesn't work. If mylastname contains m'eachem I just get m in the textbox with the code above. If I do this
mylastname = replace(mylastname,"'","''")
before the response.write, I get exactly the same.

That is the first thing I tried.
 
Do this instead...

Code:
Response.Write "<td width='257' height='30'><input type='text' name='txtLastName' size='20' maxlength='20' value = [!]""[/!]" & mylastname & "[!]""[/!]></td>"

And don't double the apostrophes.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
>mylastname = replace(mylastname,"'","''")
[tt]mylastname = replace(mylastname,"'","&#x27;")[/tt]
 
no need to use replace function...try this:

Code:
Response.Write "      <td width='257' height='30'><input type='text' name='txtLastName' size='20' maxlength='20' value = [red]""" & mylastname & """[/red]></td>"

-DNG
 
Great, thanks to all. Just have to stop people entering " in a name!
 
that shouldnt be a problem...
you can use server.htmlencode() function

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top