This is a public Forum  publicRSS

Topic

    Vinay Kumar
    Restrict the user for limited Characters and digits for that...
    Topic posted June 6, 2018 by Vinay KumarExplorer 
    45 Views, 7 Comments
    Title:
    Restrict the user for limited Characters and digits for that Inputs on Screen
    Content:

    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?

     

    Version:
    May 01 2018

    Answer

     

    • 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.

      Cheers,
      Jasmine

    • 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:

      http://documentation.custhelp.com/euf/assets/devdocs/unversioned/PolicyAutomation/en/Default.htm#Guides/Policy_Modeling_User_Guide/Screens/Choose_how_data_is_collected.htm#Text

      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.

      Thanks,

      Vinay.