Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do custom validation in Semantic UI?

In Semantic UI, I already know that you can validate forms, but there are only certain rules you can validate. In my signup form (in my application), I want to check if a user with a certain email already exists in the server. If the email exists, the user cannot signup with that certain email. How would I achieve this?

like image 295
mathenthusiast8203 Avatar asked Jan 26 '16 15:01

mathenthusiast8203


1 Answers

You can add custom validation rules to your form.

$.fn.form.settings.rules.myCustomRule = function(param) {
    // Your validation condition goes here
    return (param <= 10 )? true : false;
}

To pass parameters to a rule, use bracket notation in your settings object.

 rules: [
         {
           type   : 'myCustomRule[param]',
           prompt : 'Custom Error'
         }
       ]

Here is the doc Adding custom validation rule in semantic

like image 111
Nighisha John Avatar answered Nov 04 '22 11:11

Nighisha John