Jump to content
  • 0

Help With Input Rules In Universal Module


Brashquido

Question

Hi All,

 

So, I am not a coder. I have added a service option to a product to capture the Client ID of any referring customers. I would like to create a JSON rule to validate that anything entered into this field is numeric and 4 digits long. I have reviewed the doco on input rules, having no background in this I have no idea where to start.

 

http://docs.blesta.com/display/user/Universal+Module#UniversalModule-InputRules

 

I am already using the JSON code in the doco example to validate the hostname entries. Anyone able to assist?

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Something like the following may work (untested):

{
"hostname":{
    "valid":{
        "rule":"isEmpty",
        "negate":true,
        "message":"Hostname must not be empty"
    }
},
"configoptions[client_id]":{
    "valid":{
        "rule":["matches","/^[0-9]{4}$/"],
        "message":"Please enter a four digit number for the referring client."
    }
}
}

You will need to change the name of the config option ("configoptions[client_id]") field to the one that you created.

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