1
0
-1

Dear Team,

i have an small requirement where i have got 37 field where the only number input it 0,1,2,3. what i want is user should not type any number only this number i want to type. 

is their any provision in joget i can put this kind of validation.

and i can not use the drop drown because we are going to sum the value of this by click on button.

    CommentAdd your comment...

    3 answers

    1.  
      1
      0
      -1

      I think you can add Custom Html, in that you can write javascript to validate the mentioned scenario.

        CommentAdd your comment...
      1.  
        2
        1
        0

        Hi Mathew - 

        you leverage the default validator on the field and only accepts number input 0,1,2,3,

        in the text field,  select default validators and enter a custom regular  expression. for your requirements the expression would : 

        ^[0-3]

        below is some reading on how you would achieve this - 

        Default Validator

        https://stackoverflow.com/questions/19715303/regex-that-accepts-only-numbers-0-9-and-no-characters


        best wishes,


        Tony 

          CommentAdd your comment...
        1.  
          1
          0
          -1

          Dear Varun,


          thanks for the advise and i was looking for JS and found for the validation and found this

          <script>

          $('#Evaluation_1').keyup(function(){
            if ($(this).val() > 3){
              alert("No numbers should be between 0 to 3 ");
              $(this).val('0');
            }
          });

          </script>


          this is working, but if you can help i have got 37 text field and i want apply same validation for all can their be any method using same function above id did from my side but did not work.


          <script>
          var Eval = $('select[name^=Evaluation]');
          Eval.keyup(function(){
          if ($(this).val() > 3){
          alert("No numbers above 3");
          $(this).val('');
          }
          });
          </script>

          1. Varun Raj

            Add event listener for the fields you want to validate, and call the function which you have defined.

            //input listener for field1
                    var varField1= FormUtil.getField("field1");
                    varField1[0].addEventListener('input', function () {
                        yourValidationFunction();
                    });


            Hope this helps !! 

          CommentAdd your comment...