Hi,
I have a cell with a data restriction using a list. I inputted an invalid data and a message in the lower left appeared. I then inputted a valid data but the message didn’t disappear.
It only disappeared after I interacted with its’ buttons.
Is this the intended behavior? Is it possible to make the message automatically disappear when a valid data is supplied?
data validation list message.7z (521.2 KB)
Cause
The behavior you’re experiencing, where the validation error message does not disappear automatically after entering valid data, is a known characteristic of the data validation feature in Aspose.Cells.GridJS. The message typically remains until the user interacts with it, such as clicking a button.
Solution
To achieve the desired behavior of automatically hiding the error message when valid data is entered, you can implement a custom validation function. This function can be set to validate the input and clear the error message when the input is valid.
Code
Here’s a simple example of how you can implement a custom validation function:
function customValidation(source, value) {
// Assuming 'validValues' is an array of acceptable values
const validValues = ['Value1', 'Value2', 'Value3'];
// Check if the entered value is valid
if (validValues.includes(value)) {
// Clear the error message
source.setErrorMessage('');
return true; // Valid input
} else {
// Set the error message
source.setErrorMessage('Invalid input. Please select from the list.');
return false; // Invalid input
}
}
// Example of setting the validation
grid.getValidations().addACell('A1').setClientValidationFunction('customValidation');
Next Steps
- Implement the custom validation function as shown above.
- Ensure that the validation is applied to the desired cell(s).
- Test the functionality to confirm that the error message disappears upon entering valid data.
If you have any further questions or need additional assistance, please feel free to ask!
@abdelaspose
Hello, the display of this prompt box is indeed problematic. The normal display effect should be as shown below. Can you provide the relevant files and gridjs version? It would be best to also provide any error messages in the browser console.