Jump to content
  • 0

Help With Input Rules In Universal Module


Question

Posted

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?

1 answer to this question

Recommended Posts

  • 0
Posted

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.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...