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

Perhaps reading Quote and Quote-like Operators while paying particular attention to interpolation will help you understand this.

use strict; use warnings; use feature q/say/; my $name = q/jone/; say q/name is $name (non-interpolating)/; say qq/name is $name (interpolating)/;

🦛

Replies are listed 'Best First'.
Re^8: Onkeyup not working
by frank1 (Monk) on Oct 08, 2023 at 12:39 UTC

    still its not workin out. this is the script

    it only prints $name not jone

    #!/usr/bin/perl -wT use strict; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); my $name = "jone"; 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> $name <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

      (Re?)read the documentation liked by hippo above:

      print <<'HTML';

      should be:

      print <<"HTML";

      for example:

      my $derp = "jone"; print <<'HTML'; <h3>$derp</h3> HTML

      Returns:

      <h3>jone</h3>

      Thought it'll probably throw errors due to jQuery's use of $ in the JavaScript. To make life easier on yourself, take the advice from elsewhere in the thread, use a templating system to separate your perl code from everything else. Tutorials -> Framework, Templating, and Content Management Systems. If you're not exiting some existing code (or even if you are and it's going to grow significantly) consider making life easier (and fun) using Mojolicious::Lite.

        tho i dont have script problem. the only problem is this regex var emailReg = /^(?!.*_)\w+(\.-?\w+)*@\w+(\.-?\w+)*(\.\w{2,3})/; since it includes things like @ thats why problem comes.

        but when i try to remove regex . the script work well with other JavaScript codes