This is a public Forum  publicRSS


    Vinay Kumar
    Restrict the user for limited Characters and digits for that...
    Topic posted June 6, 2018 by Vinay KumarJourneyer 
    22 Views, 7 Comments
    Restrict the user for limited Characters and digits for that Inputs on Screen

    I am having Text and Number Inputs on OPA Interview page. Can i restrict the user for limited Characters and digits for that Inputs on Screen??

    For Example, i am having Text Input - Pin/Zip Code where user can enter maximum Upto 6 digits. if user enters 7th digit , Text Input should not allow in text box.

    I am able to achieve same functionality through Java Script or Regular Expressions by dispalying error message that it should not be more than 6 digits. Is there any other way in OPA to achieve the same & exact functionaity in OPA?


    May 01 2018



    • Jasmine Lee

      Regular expressions are the standard way to do this in OPA.

    • Jasmine Lee

      You could create rules using text functions (e.g. Find the length of a text string), but you'd get more flexibility with regular expressions. So if you needed to validate more than just the length of the text string (e.g. also validate that certain characters were numbers), then regular expressions are the way to go.


    • Vinay Kumar

      Thanks Jasmine Lee for valueble information.

    • Davin Fifield

      If it's a fixed length sequence of characters, with optional formatting, then Masked text inputs are the best solution:

      This is certainly perfect for 5 digit US zipcodes

    • Vinay Kumar

      Hi Davin,

      our requirement is not for fixed length of sequence of numbers and as user should not enter more than 6 characters.   

       $("label:contains('Zip Code:')").parent().siblings().children().prop('maxlength',6);    in Java script is working for Restricting the user for limited Characters and digits for OPA Input Fields.

    • Jasmine Lee

      Why use java script instead of masked input text boxes or regular expressions?

    • Vinay Kumar

      Hi Jasmine,

       Masked Input is for Fixed length of Characters or digits and Regular expressions won't work for Number type of Attribures. Regular expressions will work for throwing error Immediately or On Navigate if that Attribute is not satisfying condition of  Regular Expression. Here our requirement was User can enter minimum one Character and Maximum upto 6 Characters. On entering 7th Character,Input text should not take 7th Character.