£ on input [type = text]

I have jQuery setting a value input[type=text]

like so:

if(theVal=="EPC/Floorplan"){
    $('#s3').val("£100.00").attr("disabled","disabled");
    $('.priceUpdate button').hide();
}else if(theVal=="EPC"){
    $('#s3').val("£75.00").attr("disabled","disabled");
    $('.priceUpdate button').hide();
}else{
    $('#s3').val("£0.00").removeAttr("disabled");
    $('.priceUpdate button').show();
}

      

However, the input then looks like this:

Input with £

I also have the following meta tag:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Here is the site in question. Choose any option from the dropdown menu

+3


source to share


3 answers


Try adding an attribute charset

to the included script:



<script src="custom.js" type="text/javascript" charset="utf-8"></script>

      

+2


source


Use unicode:

\u00A3

      



In your example:

if(theVal=="EPC/Floorplan"){
    $('#s3').val("\u00A3" + "100.00").attr("disabled","disabled");
    $('.priceUpdate button').hide();
}else if(theVal=="EPC"){
    $('#s3').val("\u00A3" + "75.00").attr("disabled","disabled");
    $('.priceUpdate button').hide();
}else{
    $('#s3').val("\u00A3" + "0.00").removeAttr("disabled");
    $('.priceUpdate button').show();
}

      

+1


source


The server already provides a header Content-Type

with the encoding set to ISO-8859-1

. The browser only counts your element <meta>

, unless the server provides that header itself.

Here is the relevant portion of the Firebug trace:

HTTP/1.1 200 OK
Date: Wed, 14 Mar 2012 14:19:16 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.2.17
Content-Type: text/html; charset=ISO-8859-1

      

Try setting up the server (or your server-side code) to set the content encoding instead UTF-8

.

+1


source







All Articles