How to add validation in the custom form in SCA

When we created a new form in SCA we can add standard validation to the Website. We can add the validation based on the field’s acceptable values. The example form is added below

We can add validations in a model file when submit the form. The example code is added below

validation: {
            salonname: {
                required: true,
                msg: _('Salon Name is required').translate()
            },
            fullname: {
                required: true,
                msg: _('Full Name is required').translate()
            },
            role: {
                required: true,
                msg: _('Role is required').translate()
            },
            phone: {
                required: true,
                msg: _('Phone Number is required').translate(),
                pattern: /^\s*(?:\+?(\d{1,3}))?[-. (]*(\d{3})[-. )]*(\d{3})[-. ]*(\d{4})(?: *x(\d+))?\s*$/
            },
            email: {
                required: true,
                msg: _('Email is required').translate(),
                pattern: 'email'
            }
        }

Leave a comment

Your email address will not be published. Required fields are marked *