Expression or reg-ex for javascript or adobe livecycle tools

后端 未结 1 1582
生来不讨喜
生来不讨喜 2020-12-12 05:03

What will be the expression for restricting a user to enter either 5 lines or 375 characters in a scrollable text field?

I tried theese:

([A-Z])\\

相关标签:
1条回答
  • 2020-12-12 05:14

    Try this:^((.+\n){0,4}.+|.{1,375})$

    $(document).ready(function() {
    
      $("#text_string").focusout(function() {
        var res, text_string = $("#text_string").val();
        if (text_string != null) {
    
          res = text_string.match(/^((.+\n){0,4}.+|.{1,375})$/);
          console.log(res);
          if (!res) {
            $("#text_string").val("");
          }
        }
      });
    
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <textarea name="" id="text_string" cols="30" rows="10"></textarea>

    0 讨论(0)
提交回复
热议问题