Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

104
Vistas
A <div> is created in JavaScript for dollar sign

I have this Razor code:

<script>
    app.run(function () {
        var key = $('#@Model.HtmlId');
        key.inputFilter(function (value) {
            return new RegExp('@Html.Raw(RegularExpressions.KeyPattern)').test(value);
        });
    });
</script>

And this is my RegularExpressions class:

public class RegularExpressions
{
    public const string KeyPattern = @"^[a-z-]+$";
    
    // other patterns
}

And what I get in my rendered HTML (page source in browser) is this:

<script>
    app.run(function () {
        var key = $('#key_Key_b13dca0421ac4740b5e177b80c002c25');
        key.inputFilter(function (value) {
            return new RegExp('^[a-z-]+$').test(value);
        });
    });
</script>

However, I get this JavaScript error in my browser console:

Uncaught SyntaxError: Invalid or unexpected token

And when I click on it, I see this code:


    app.run(function () {
        var key = $('#key_Key_5be9a1756c8549199d3b37e0eea35bba');
        key.inputFilter(function (value) {
            return new RegExp('^[a-z-]+</div>).test(value);
        });
    });

What is wrong here?

7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos