ReferenceError: PasswordValidator is not defined.

kun1
Tera Expert

Test

5 REPLIES 5

ajit kasabale
Tera Expert

 Hello ,

Please try below code as we are in client sript we must have to call the script via the glideAjax

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

var ga = new GlideAjax('PasswordValidator');
ga.addParam('sysparm_name', 'validatePassword'); // Call the validate method in Script Include
ga.addParam('password', newValue); // Pass the new password value to the script include

ga.getXMLAnswer(function(response) {
var result = JSON.parse(response); // Parse the JSON string returned by Script Include
if (!result.isValid) {
var errorMsg = "Password validation failed:\n" + result.errors.join("\n");
alert(errorMsg);
g_form.setValue('password', '');
control.setError(errorMsg); // Optionally set an error on the field
}
});
}

Hi @ajit kasabale ,

 

kun1_0-1729666078153.png

 

 

getting unhandled exception error while using above client script

ajit kasabale
Tera Expert

Hello ,

I got why it's happening some time we have done some mistakes in configuring the variables so please check if there is any client script or UI policy is conflicting at that time we are facing this type of issue I also observed this type of issue, so please check catalogue item configurations like variable, variable set, client script, or UI policy.

ajit kasabale
Tera Expert

Also please remove the logs from the client script