I’m using Unicode value ‘✔’ to display a tick mark in text area.
Now I need to fetch the value in text area and need to check whether symbol is present in that?
When I’m fetching the text area value I’m getting a checkbox without tick like symbol instead of tick symbol.
How can I compare this Unicode value is exist or not?
// Not working.
if( document.getElementById('location').value.charAt(0) == '✔')
alert("symbol');
Your problem is that
✔is an HTML entity that represents ✔ in HTML but it is just a string in JavaScript. In JavaScript you’d want'✔'(the raw character) or'\u2714':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&#x....;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.