Script check password

CE_
Tera Contributor
 
1 ACCEPTED SOLUTION

Muhammad Khan
Mega Sage
Mega Sage

Try with below script.

function onChange(control, oldValue, newValue, isLoading) {

        if (isLoading || newValue == '') {
                return;
        }

        // now check the length
        if (newValue.toString().length != 16) {
                alert("Password should have exact 16 letters");
                g_form.clearValue('backend_name_of_your_password_variable'); // Make sure to use backend name of your variable.
        }
}

 

You can also utilize Variable Validation Regex to create regex as per your need and use that regex for validation of your variables, however it is not available for all types of variables.

MuhammadKhan_0-1670420461715.png

 

View solution in original post

6 REPLIES 6

Use below script.

 

 

function onSubmit() {
    //Type appropriate comment here, and begin script below
    var pass = g_form.getValue('backend_name_of_your_password_variable');

    if (pass != '') {
        if (pass.length < 16) {
            alert("Password should have minimum 16 letters");
			g_form.showFieldMsg('backend_name_of_your_password_variable', 'Password should have minimum 16 letters', 'error', true);
            return false;
        }
    }

}

 

 

 Use alert or field message as per your need.

Community Alums
Not applicable

Hi, try this: (replace fieldValue with newValue)

 

if(newValue.length != 16){

alert("Password should have exact 16 letters");

g_form.clearValue('Password');

}

 

Mark my response as correct/helpful if this solves your issue