Due to security issue reported. where they were intercepting the request and copying the pan number
we encrypted the pan id field. but now there is different issue
function EncryptPan(refId) {
alert("Hi");
alert($('#txtPan').val());
$('#hdnPan').val(EncryptPassword($('#txtPan').val(), refId));
$("#txtPan").val('********');
}
the pan is encrypted and stored in hidden field
in txtPAN some masked value is displayed. this is fine
the issue which is occuring is when no value is entered in txtCode textbox required field validator runs message comes Please Enter Code
and at this time value in txtPan is ***
now if validation fails i want to set value in txtPan back to the pan number user entered. how to do this

Aniket NarvankarPosted Mar 3, 2025, 10:29 AM
thanks
but i am not understanding exactly where to call this function
Sophia CarterPosted Mar 3, 2025, 10:27 AM
It seems like you are facing an issue with restoring the original value in the txtPan textbox if validation fails due to the RequiredFieldValidator for txtCode triggering. Here's how you can address this:
1. In your current setup, you are masking the value in txtPan with asterisks ('****') after encrypting it. This is a common technique to hide sensitive data on the client-side.
2. To revert txtPan back to its original value when validation fails, you can make use of JavaScript/jQuery along with the ASP.NET Validator controls.
3. You can achieve this by having a JavaScript function that will be triggered when validation fails on txtCode. This function will read the original pan number stored in the hidden field (hdnPan) and update txtPan with this value.
Below is a simplified approach to achieve this:
4. Next, you need to call this function when the validation for txtCode fails. You can achieve this by handling the validation error event or adding a custom validation function to execute it.
5. Consider adding a client-side validation function to check if the txtCode has a value. If not, trigger the restoration of the original pan value.
6. Ensure that the RestorePanValue function is called when needed, incorporating it into the validation logic to restore the original pan value upon validation failure.
By following these steps, you should be able to handle the scenario where the txtPan value needs to be reset to the user-inputted PAN if the validation fails for txtCode. This will help maintain a smooth user experience while ensuring data integrity. Let me know if you need further clarification or help with implementing this solution.