How do I apply a regex to a form field using the Kademi forms plugin?

33 views Asked by At

I'm using the jquery.forms plugin in Kademi and I have a custom field which is a membership number. How can I add a regular expression to validate the field?

1

There are 1 answers

0
Wesley Tuzza On BEST ANSWER

The Kademi forms plugin looks for a class called "regex", if found it will then pull the regex from a data-regex attribute and run the value of the input through the regex. Here is an example:

<input type="text" name="newName" required="true" id="newName" class="form-control regex required" data-regex="^[a-z0-9-]+$"/>

There are some docs about the plugin http://docs.kademi.co/ref/javascript/jquery-forms-plugin.html

I hope this helps you :-)