Jump to content
  • 0

Help About Input Rules for Text and Password Fileds


SimpleAja

Question

Hi there,

Please help me about using input rules in Universal Modules. I want to apply validation that can be typed in the text and password form fields.

  • Validate text input field for hostname. Allowing only letter and number with a maximum length of 24 character
  • Validate input type password for password. That must consists one lower case letter, one upper case letter, one digit, 10-24 length, allow special character like !@#$%^&*()+_-= but space not allowed.

 

When I use WHMCS billing system, I was able to make  input validation for additional form fields. By learning regex tutorial that is widely available on the internet. Also I can simulate on this website: https://www.regextester.com to testing the regex.

 

Thanks

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

In the Universal Module, you can define service options, which are fields that customers can enter when they order a service.

You mentioned using regular expressions to validate the input, which you can do by defining them in the "Input Rules" section for each of your fields as described in the Universal Module documentation.

e.g.

{
    "hostname":{
        "valid":{
            "rule":["matches", "/^[a-z0-9]{1,24}$/i"],
            "message":"Please enter an alphanumeric hostname between 1 and 24 characters in length."
        }
    },
    "password":{
        "valid":{
            "rule":["matches", "/^[a-z0-9\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\+\\_\\-\\=]{10,24}$/i"],
            "message":"Please enter an alphanumeric password between 10 and 24 characters in length. You may also include any of the following characters: !@#$%^&*()+_-="
        }
    }
}

My example does not enforce a minimum 1 lower case character, 1 upper case character, or 1 digit, but you can update the regular expression to whatever you need.

Link to comment
Share on other sites

  • 0

Not working in blesta with the following regex:

"rule":["matches", "/((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\W_]).{6,18})/i"],

requires at least 1 lower case character, 1 upper case character, 1 number, 1 special character. length between 6 and 18 character.

But it works when tried through Regex testing https://www.regextester.com/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...