The CreatorCon Call for Content is officially open! Get started here.

variable should be only accept email as string. its should accept any other information.

Atchutaram
Tera Contributor

Hi Team,

                    I am trying to create a variable which should accept only email. How can i achieve this without writing an acl? 

 

BR,

AtchutRam

1 ACCEPTED SOLUTION

swathisarang98
Giga Sage

Hi @Atchutaram ,

 

If you are trying for any field or variable in catalog item then you can use validation regex,

swathisarang98_0-1708951585390.png

If for a field inside table , then you can write onchange client script as below,

 

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    var mail = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/;
    if (!newValue.match(mail)) {
        alert('You have entered an invalid email address format! example: example@gmail.com' );
        g_form.clearValue('field_backend_name');

    }

}

 

 

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

 

View solution in original post

3 REPLIES 3

Sarika S Nair1
Kilo Sage

Hi @Atchutaram . 

Create variable of type 'Email' 

 

SarikaSNair1_0-1708951495132.png

 if that also not resolving your issue , create one single line text type variable and add validation regex as Email like  below 

SarikaSNair1_0-1708952129863.png

 

swathisarang98
Giga Sage

Hi @Atchutaram ,

 

If you are trying for any field or variable in catalog item then you can use validation regex,

swathisarang98_0-1708951585390.png

If for a field inside table , then you can write onchange client script as below,

 

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    var mail = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/;
    if (!newValue.match(mail)) {
        alert('You have entered an invalid email address format! example: example@gmail.com' );
        g_form.clearValue('field_backend_name');

    }

}

 

 

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

 

AB1998
Tera Contributor