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(); 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 }