If you are replacing the apostophe so you can put the value in a database then there is a better way to do this... please advise.
Main Topics
Browse All TopicsIs there a way with my text box below i can replace a ' (apostrophe) with a space, If it is entered:
[code]
<input name="heading<%=i%>" type="text" size="100">
[/code]
can this be done with javascript/asp or html?
Picco
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Use parameters when adding, updating and deleting records.
You not only solve the apostrophe problem, but you will avoid most cross site scripting attacks. When you build a SQL statement on the fly from input, the input becomes executable SQL. The vast number of different encoding methods makes it impossible to proactively filter all harmful input.
A parameter will never be treated as executeable SQL, so it is tremendously safer. (It is also faster for complex statements.)
Here is an example:
Dim cmd, conn, RS, cmdText, param, numAffected, connectionString
Const adVarChar = 200
Const adParamInput = = &H0001
Const adExecuteNoRecords = &H00000080
connectionString = Application("examples") ' e.g. "Provider=Microsoft.Jet.OL
Set cmd = Server.CreateObject("ADODB
Set conn = Server.CreateObject("ADODB
conn.Open(connectionString
Set cmdText = "INSERT INTO members (username,password) " &_
"VALUES (@username,@password);"
Set param = cmd.CreateParameter(@usern
cmd.Parameters.Append param
Set param = cmd.CreateParameter(@passw
cmd.Parameters.Append param
cmd.commandText = cmdText
cmd.Execute numAffected,, adExecuteNoRecords
When you retieve your data and need to display it in a web page you can use Server.HTMLEncode(rs("what
That way you do not alienate Mr. O'Brian.
Regards,
Rod
this is how i would do it in ASP in order to use apostrophe in a search engine or any text form, this is used when selecting items from a SQL database.
when you are declaring your variables use a replace statement, sort of like this.
testname = Request.QueryString("Name"
testname = Replace (testname ,"'","''")
that should replace an ' with a (space)
Hope this helps.
I realize you are fairly new here, so I suggest you read the EE Guidelines regarding grading standards at:
What's the right grade to give?
http://www.experts-exchang
And specifically this section:
<quote>
C: Because Experts' reliability are often judged by their grading records, many Experts would like the opportunity to clarify if you have questions about their solutions. If you have given the Expert(s) ample time to respond to your clarification posts and you have responded to each of their posts providing requested information; or if the answers, after clarification, lack finality or do not completely address the issue presented, then a "C" grade is an option. You also have the option here of just asking Community Support to delete the question.
Remember, the Expert helping you today is probably going to be helping you next time you post a question. Give them a fair chance to earn an 'Excellent!' grade and they'll provide you with some amazing support. It's also true that a "C" is the lowest grade you can give, and the Experts know that -- so use it judiciously.
Only the Moderators and Page Editors have the choice to give a D grade. Beyond that, in a practical sense, the grading guidelines have "softened" a bit over the last year or two; one might expect that the majority of grades would be Bs (a standard "bell" curve), but the fact is that the culture of the site has caused there to be an inordinately high percentage of As. The Moderators have been instructed to ensure that the As they award are actually "Excellent" answers. Similarly, the C grade is the lowest that can be given by a member, a fact which should be kept in mind when grading as well.
The use of a C in a vindictive manner is likely to be changed by a Moderator. You may not like the answer you get, and in some cases, and you may not like the way it is delivered, but if it is deemed to be accurate, no less than a B is an acceptable grade.
</quote>
Thanks.
Business Accounts
Answer for Membership
by: hongjunPosted on 2005-04-27 at 04:32:31ID: 13874933
Try something like this
.length-1) == '\'' )
<script language="JavaScript" type="text/javascript">
<!--
function fun(obj) {
if ( obj.value.charAt(obj.value
obj.value = obj.value.replace("'", "");
}
//-->
</script>
<form name="myform" method="post" action="" onsubmit="return validate()">
<input name="heading<%=i%>" type="text" size="100" onkeyup="fun(this)">
</form>
hongjun