Your problem is that ✔
is an HTML object that represents ✔ in HTML, but it is just a string in JavaScript. In JavaScript, you want '✔'
(raw character) or '\u2714'
:
if(document.getElementById('location').value.charAt(0) == '\u2714') alert("symbol"); else alert("not there");
Demo: http://jsfiddle.net/ambiguous/WCdCg/
The HTML ....;
notation uses decimal numbers, the JavaScript '\u....'
notation uses hexadecimal. Converting 10004 to hexadecimal yields 2714. You can also use ....;
in HTML if you want to use hexadecimal there as well, for example ✔
is ✔. Using just hexadecimal is probably easier than dealing with the base conversions.
source share