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

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

 

 -

Community Alums
Not applicable

just have -- return false -- statement in the onSubmit client script.. so that it will not get submitted

 

function onSubmit() {
var password = g_form.getValue('password_field_back_end_name').toString().length;
    if(password != 16) {
		alert('Password should have exact 16 letters');
		return false;
	}
}


-