clicks

illegal character in input string not working in javascript. how to resolve?

121 views Asked by At

I wrote a code to alert the "[email protected]" like below code :

<button onclick="myfunction('[email protected]')">clicks</button>
<script charset="UTF-16">
function myfunction(str)
{
    alert(str);   
}
</script> 

But it alerted the result like [email protected] Also in source its looking like below:

enter image description here

2

There are 2 answers

0
Ammar Yaqoob On

You need to save your file with unicode encoding then try it

enter image description here

0
Learn Codingfun On

Could you try if this work?

   <button onclick="myfunction()">clicks</button>
<script charset="UTF-16">
function myfunction(str)
{
var str  = '[email protected]' ; 

    alert(str);   
}
</script>