I have a masked text box (number of days) in a form that has to always have an integer inside. It cannot be blank when the user pressed the "OK" button on the form.
What I need is when the user pressed "OK", if the text box is not filled as it should be, a tool tip come up and show the user they need to enter information there before they can proceed.
What should I use for this? I'm guess开发者_高级运维ing a variation of a Tool Tip and Masked Text Box, I just need a push in the right direction as I can't find the information anywhere.
use a regex control to validate the input and a required field validator. on the validation you could fill out a div with display:none then use jquery tooltip (or something like it) to display a tooltip with the information in that div. thats my first blush response anyway.
it will work for you
private void button1_Click(object sender, EventArgs e)
{
if (maskedTextBox1.Text == "")
this.errorProvider1.SetError(this.maskedTextBox1, "Plz fill it");
else
this.errorProvider1.Dispose();
}
Use Validation controls provided by asp.net. You can set a required field validator and a Regular Expression Validator for the input field. Then, set the CausesValidation property of the input control to true. Validator controls provide error message labels which will be visible if the input value is invalid. For more information, you can visit http://msdn.microsoft.com/en-us/library/debza5t0.aspx
精彩评论