How to do to show the accents from a javascript file?

1

I have a jsp in which it is sent to call a javascript file in the following way

<script type="text/javascript" src="<c:url value="/webresorces/js/validacion.js" />"></script>

The file js contains the validations of the fields of the form that is in my jsp, I have something like this

var validator = $("#consulta").validate({ 
  rules: {
    idPago:{        
      number: true,
      maxlenght: 16
    }
  },
  messages:{
    idPago{
       number: "El campo debe ser num\u00e9rico",
       maxlenght: "El campo debe ser de 6 posiciones"
    }

  }
})

The problem is that it does not take the accents, rare characters come out, and it is that previously this code to validate the fields had it inside the jsp and put the normal accents and if I took them, but placing the validation in an external file does not work well

what can it be? I already tried placing the words with the normal accent and using in unicode but none takes them

    
asked by Root93 12.07.2018 в 06:03
source

2 answers

1

To make sure that your JSP generates an HTML with UTF-8, you must add the following in the first line of the .jsp file:

<%@ page contentType="text/html; charset=UTF-8" %>
    
answered by 12.07.2018 / 09:56
source
1

Add utf-8 on your page

<head>
  <meta charset="UTF-8">
</head>
    
answered by 12.07.2018 в 06:20