About displaying double quotes and single quotes in an input box

Source: Internet
Author: User
Tags date tostring
Show about the display of double quotes and single quotes in the input box





Foreground display Solution:


method One:


single quotes <input type= "text" value= "'" >


double quotes <input type= "text" value= ' "' >


Method II:


single quotes <input type= "text" value= "'" >


double quotes <input type= "text" value= "" ">








from the background to read the data foreground display solution:


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, you can add rich display mode


sStr = (new Date (OSTR)). ToString ();


break;


Default:


sStr = String (OSTR);


}


sStr = sstr.replace (/\ "/g," ""); The issue of double quotes in the input box


sStr = sstr.replace (/\ '/g, ""); Display single quotes in an input box


return sStr;


}


%>





<%


//Test


var str = "\" Gray beans baby. NET (magical season) \ "";


var str = new Date ();


%>


<br>


<input type= "text" value= "<%=str%>" style= "width:200px" >[is not displayed properly]<br>


<input type= "text" value= "<%=foramtvalue (str)%>" style= "width:200px" >[normal display]<br>








VBScript version:





<% @Language = "VBScript"%>


<%


function Foramtvalue (OSTR)


Select Case VarType (OSTR)


case "Vbdate"


' direct ToString () conversion, you can add rich display mode


sStr = CDate (ostr)


Case Else


sStr = CStr (ostr)


End Select


sStr = Replace (SStr, "" "," ")" "The box shows the double quotation mark problem


sStr = Replace (sStr, "'", "") "the input box displays the single quotation mark question


Foramtvalue = SStr


End Function


%>





<%


' Test


Dim str


str = "" "Grey bean Baby. NET (Magical season)" ""


%>


<br>


<input type= "text" value= "<%=str%>" style= "width:200px" >[is not displayed properly]<br>


<input type= "text" value= "<%=foramtvalue (str)%>" style= "width:200px" >[normal display]<br>














Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.