in reply to Re: Onkeyup not working
in thread Onkeyup not working

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: Onkeyup not working
by Corion (Patriarch) on Oct 07, 2023 at 15:07 UTC

    I don't believe you.

    See the following Javascript line in your HTML:

    var emailReg = /^(?!.*_)\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})/;

    Again, follow the steps in my original post.

      This is the error i get

         Unrecognized escape \\w passed through at file.pl line 8.: /usr/....

      Second

      when i add this print <<'HTML'; my javascript just report this Uncaught SyntaxError: invalid escape sequence

      #!/usr/bin/perl -wT use strict; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); print "Content-type: text/html\n\n"; print <<HTML; <!DOCTYPE html> <html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquer +y.min.js"></script> </head> <body> <input type="text" class="keyup-email text-input" name="7" value=""> <button type="butt +on" id="m1p" class="edBtn"> submit </b> </button> <script> \$('.keyup-email').keyup(function() { var inputVal = \$(this).val(); var emailReg = /^(?!.*_)\w+([\.-]?\w+)*\@\w+([\.-] +?\w+)*(\.\w{2,3})/; if(!emailReg.test(inputVal)) { \$(".edBtn").prop("disabled", true); } else if(inputVal == 'test\@test.com') { \$(".edBtn").prop("disabled", true); }else{ \$(".edBtn").prop("disabled", false); } }); </script> </body> </html> HTML

        Yes. Once you use single quotes, you don't need to put backslashes into your Javascript anymore. You can remove one backslash from each escape, turning \\w back into \w, and removing most of the others.

        Again, consider moving your HTML into external files.

Re^3: Onkeyup not working
by kcott (Archbishop) on Oct 07, 2023 at 18:03 UTC