About displaying double quotes and single quotes in an input box
Source: Internet
Author: User
About displaying double quotes and single quotes in an input box
Foreground Display Solution:
Method One:
Single quotation mark <input type= "text" value= "'" >
Double quotes <input type= "text" value= ' "' >
Method Two:
Single quotes <input type= "text" value= "& #39;" >
Double quotes <input type= "text" value= "& #34;" >
Read foreground display solution from background:
We should add the conversion when we read the value from the database to the foreground display
JavaScript version:
<% @Language = "JavaScript"%>
<%
function Foramtvalue (OSTR)
{
Switch (typeof (OSTR))
{
Case "Date":
Direct ToString () conversion, can add rich display mode
SSTR = (new Date (OSTR)). ToString ();
Break
Default:
SSTR = String (OSTR);
}
SSTR = sstr.replace (/"/g, & #34;"); Double quotation mark problem in input box
SSTR = sstr.replace (/'/g, & #39; "); Display single quotes in an input box
return sStr;
}
%>
<%
Test
var str = "Grey peas baby. NET (Magic season)" ";
var str = new Date ();
%>
<br>
<input type= "text" value= "<%=str%>" style= "width:200px" >[does not display correctly]<br>
<input type= "text" value= "<%=foramtvalue (str)%>" style= "The width:200px" is normally displayed >[
VBScript version:
<% @Language = "VBScript"%>
<%
function Foramtvalue (OSTR)
Select case VarType (OSTR)
Case "Vbdate"
' Direct ToString () conversion, can add rich display mode
SSTR = CDate (OSTR)
Case Else sStr = CStr (OSTR)
End Select
SSTR = Replace (SStr, "" "", "& #34;") " Double quotation mark problem in input box
SSTR = Replace (sStr, "'", "& #39;") Display single quotes in an input box
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.