skip to Main Content

I am using the dynamic method where the name and id of input the element will be in different languages but I am facing this issue. Like if the input id of the element is a mixture of English and Arabic. Its value is not accessible in jquery.

HTML Code

<input type="text" name="relation_كرتون|CARTON" id="relation_كرتون|CARTON" class="form-control" required /> (not accessible in jquery)

<input type="text" name="relation_CARTON" id="relation_CARTON" class="form-control" required /> (accessible in jquery)

Javascript Code

var getId = $("#relation_كرتون|CARTON").val();
(not accessible here)

var getId = $("#relation_CARTON").val();
(accessible here)

It gives me the error relation_كرتون|CARTON is undefined. input element id is not accessible.
But when the element id is in English its value is accessible. Please help.

2

Answers


  1. Chosen as BEST ANSWER

    This escape sign | is giving the issue. But when I use the below code. It works fine with the escape sign too.

    document.getElementById("relation_كرتون|CARTON").value


  2. go to notepad, open your jQuery script and click ‘Save as’ and then make sure encoding is ‘UTF-8’

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search