Site icon Hip-Hop Website Design and Development

WordPress stripping away backslashes from HTML

Hi I’m kind of new to WordPress. I have come across this issue lately when running my webpages from my WordPress server.

I have this piece of code that clears any white spaces in the text input field. But after uploading it to the server directory, the backslashes in that peice of code is stripped away. The same happens to js file as well. Due to this I’m unable to use the js n character at all.

<script>
$(document).ready(function(){
$("input#MobileNo").on({
  keydown: function(e) {
    if (e.which === 32)
      return false;
  },
  change: function() {
    this.value = this.value.replace(/s/g, "");
   }
 });

 });
</script>

Any idea how to fix this. I have read that esc_js() can be used, but don’t know how.

WordPress is great and secure and hence I want to learn it.