From 540163abebc860d7cb0e77a55aa07da8c2faeba2 Mon Sep 17 00:00:00 2001 From: Rashmi Tiwari <99129127+rashmi269@users.noreply.github.com> Date: Mon, 20 Oct 2025 10:26:18 +0530 Subject: [PATCH 1/2] Update block_submit.js Added a validation to verify that 'someVariable' value is not null , so that the Block functionality works smoothly --- .../Catalog Client Script/Block Submit/block_submit.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Client-Side Components/Catalog Client Script/Block Submit/block_submit.js b/Client-Side Components/Catalog Client Script/Block Submit/block_submit.js index d63e2762d6..6b213b1e0c 100644 --- a/Client-Side Components/Catalog Client Script/Block Submit/block_submit.js +++ b/Client-Side Components/Catalog Client Script/Block Submit/block_submit.js @@ -1,7 +1,13 @@ //Block the user from submitting the form based on variable answer function onSubmit() { - var someVariable = g_form.getValue("someVariable"); - if(someVariable == 'No'){ + var VariableName = 'someVariable'; + var VariableVal = g_form.getValue(VariableName); + // Basic validation + if (!VariableVal) { + g_form.showFieldMsg(VariableName, 'Please answer this question before submitting.', 'error'); + return false; + } + if(VariableVal == 'No'){ var gm = new GlideModal('glide_warn',false); gm.setTitle("Submit Blocked! You can only use this form for someReason. Review someInstructions"); gm.render(); From 2bc7bee371d727d03cffc5a601163d5438aa752c Mon Sep 17 00:00:00 2001 From: Rashmi Tiwari <99129127+rashmi269@users.noreply.github.com> Date: Mon, 20 Oct 2025 12:27:46 +0530 Subject: [PATCH 2/2] Update PAN Validation.js Improves PAN validation by showing errors only for invalid input, reducing distractions and unnecessary messages. Also used newValue to take input as it is a onChange Script --- .../PAN Validation/PAN Validation.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Client-Side Components/Catalog Client Script/PAN Validation/PAN Validation.js b/Client-Side Components/Catalog Client Script/PAN Validation/PAN Validation.js index f566c0909b..2b151cae3b 100644 --- a/Client-Side Components/Catalog Client Script/PAN Validation/PAN Validation.js +++ b/Client-Side Components/Catalog Client Script/PAN Validation/PAN Validation.js @@ -1,13 +1,15 @@ function onChange(control, oldValue, newValue, isLoading, isTemplate) { if (isLoading || newValue === '') { + // Clear any previous message if the field is empty + g_form.hideFieldMsg('pan_number'); return; } - var panNumber = g_form.getValue("pan_number"); //Get the PAN card information - var panRegex = /^[A-Z]{5}[0-9]{4}[A-Z]{1}$/; // Regex for the PAN Card - if (panRegex.test(panNumber)) { - g_form.showFieldMsg("pan_number", "Valid PAN card number.", true); //Valid PAN card enterd populates this message - } else { - g_form.showErrorBox("pan_number", "InValid PAN card number.", true); //In Valid PAN card details enterd populate this message + var panNumber = newValue.toUpperCase(); // Convert input to uppercase for consistency + var panRegex = /^[A-Z]{5}[0-9]{4}[A-Z]{1}$/; + + if (!panRegex.test(panNumber)) { + g_form.showFieldMsg('pan_number', 'Invalid PAN card number.', 'error'); } + // No "Valid" message displayed to reduce distraction }