Input and Validation
This feature allows you to implement custom validation for user input, ensuring that the entered card number or text meets your criteria, while providing immediate visual and event‑based feedback, etc
Overview
Property and Event Details
Property / Event
Description
Default Value / Notes
Code Examples
Example 1: Setting Up a Custom Validation Function
// Create an instance of the SiticoneCardNumberBox control
SiticoneCardNumberBox cardNumberBox = new SiticoneCardNumberBox();
// Define a custom validation function that ensures the input is numeric and at least 12 digits long
cardNumberBox.ValidationFunction = (input) =>
{
string digitsOnly = new string(input.Where(char.IsDigit).ToArray());
return digitsOnly.Length >= 12;
};
// Set a custom error message for failed validations
cardNumberBox.ValidationErrorMessage = "Please enter at least 12 numeric digits.";
// Subscribe to the Validated event to handle validation feedback
cardNumberBox.Validated += (sender, e) =>
{
if (!e.IsValid)
{
Console.WriteLine("Validation failed: " + e.ErrorMessage);
// Update UI components, e.g., display an error label
}
else
{
Console.WriteLine("Input is valid.");
}
};
// Add the control to your form
this.Controls.Add(cardNumberBox);
cardNumberBox.Location = new Point(20, 20);
cardNumberBox.Size = new Size(300, 50);Example 2: Handling Validation Status in Your Application
Key Points
Topic
Description
Best Practices
Best Practice
Explanation
Common Pitfalls
Pitfall
How to Avoid It
Usage Scenarios
Scenario
Description
Real Life Usage Scenarios
Scenario
Example
Troubleshooting Tips
Issue
Potential Cause
Recommended Action
Review
Aspect
Review Notes
Summary
Additional Integration Example
Last updated