473,387 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Text Box Validation

I have a text box which i validate at LostFocus Event. My problem is
that if user click at cancel it also validates this thex box and
brings a error message. I do go about it in that when it is cancel
button click then it should not validate the text box and instead
unload the form.
Thanks

Jan 30 '07 #1
4 4866
Check out the validation event for the textbox and the
CausesValidation property of the cancel button.

Thanks,

Seth Rowe
On Jan 30, 4:39 am, "daudi" <dnyaku...@gmail.comwrote:
I have a text box which i validate at LostFocus Event. My problem is
that if user click at cancel it also validates this thex box and
brings a error message. I do go about it in that when it is cancel
button click then it should not validate the text box and instead
unload the form.
Thanks
Jan 30 '07 #2
Thanks Seth,
Kindly give the code as am new to vb programing
regards
On Jan 30, 2:47 pm, "rowe_newsgroups" <rowe_em...@yahoo.comwrote:
Check out the validation event for the textbox and the
CausesValidation property of the cancel button.

Thanks,

Seth Rowe

On Jan 30, 4:39 am, "daudi" <dnyaku...@gmail.comwrote:
I have a text box which i validate at LostFocus Event. My problem is
that if user click at cancel it also validates this thex box and
brings a error message. I do go about it in that when it is cancel
button click then it should not validate the text box and instead
unload the form.
Thanks- Hide quoted text -- Show quoted text -
Jan 30 '07 #3
Actually, there isn't much code involved, all you need to do is move
the code you have in the LostFocus event to the validating event. That
gives you access to the the ValidatingEventArgs object which has a
cancel property. So if the text isn't valid then just type e.Cancel =
True and then the program will automagically take care of the rest
(preventing focus from changing). After that is set, all (I think)
standard controls have a CausesValidation property that is normally
set to true. When focus changes to a new control, if this property is
set to true it fires the Validating event for the control who had the
focus last. So setting this to false (for your cancel button) will
stop the validating event from firing when you click on the button.

Hope that makes sense

Thanks,

Seth Rowe
On Jan 30, 12:00 pm, "daudi" <dnyaku...@gmail.comwrote:
Thanks Seth,
Kindly give the code as am new to vb programing

regards
On Jan 30, 2:47 pm, "rowe_newsgroups" <rowe_em...@yahoo.comwrote:
Check out the validation event for the textbox and the
CausesValidation property of the cancel button.
Thanks,
Seth Rowe
On Jan 30, 4:39 am, "daudi" <dnyaku...@gmail.comwrote:
I have a text box which i validate at LostFocus Event. My problem is
that if user click at cancel it also validates this thex box and
brings a error message. I do go about it in that when it is cancel
button click then it should not validate the text box and instead
unload the form.
Thanks- Hide quoted text -- Show quoted text -
Jan 30 '07 #4

thanks alot

daudi
On Jan 30, 8:09 pm, "rowe_newsgroups" <rowe_em...@yahoo.comwrote:
Actually, there isn't much code involved, all you need to do is move
the code you have in the LostFocus event to the validating event. That
gives you access to the the ValidatingEventArgs object which has a
cancel property. So if the text isn't valid then just type e.Cancel =
True and then the program will automagically take care of the rest
(preventing focus from changing). After that is set, all (I think)
standard controls have a CausesValidation property that is normally
set to true. When focus changes to a new control, if this property is
set to true it fires the Validating event for the control who had the
focus last. So setting this to false (for your cancel button) will
stop the validating event from firing when you click on the button.

Hope that makes sense

Thanks,

Seth Rowe

On Jan 30, 12:00 pm, "daudi" <dnyaku...@gmail.comwrote:
Thanks Seth,
Kindly give the code as am new to vb programing
regards
On Jan 30, 2:47 pm, "rowe_newsgroups" <rowe_em...@yahoo.comwrote:
Check out the validation event for the textbox and the
CausesValidation property of the cancel button.
Thanks,
Seth Rowe
On Jan 30, 4:39 am, "daudi" <dnyaku...@gmail.comwrote:
I have a text box which i validate at LostFocus Event. My problem is
that if user click at cancel it also validates this thex box and
brings a error message. I do go about it in that when it is cancel
button click then it should not validate the text box and instead
unload the form.
Thanks- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text -
Jan 30 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Otto Krüse | last post by:
Hi everyone, I'm building a GUI in which I want, amongst other things, for people to fill in there postal code. The postal codes of my country (Holland) are in this format: 1234 AB So for the...
1
by: cga1982 | last post by:
I have a text box (for a password) with a validation rule that checks this password against another text box on the form and either lets you continue or tells you that the password is incorrect and...
4
by: Fraggle | last post by:
Hi, I want to validate a text box, The user can leave it blank, or fill it in. If they fill it in then it must be a date within a certain range. How can I achieve this? Thank you very much
6
by: The Eeediot | last post by:
Hello, Folks... I'm almost becoming a regular to this newsgroup. I am trying to display the contents of an MS-SQL Text field to a TextBox in ASPdotNET. The text in this field contains all...
1
by: Stephen Adam | last post by:
Hi there, I have written a custom validation control which checks to see of an input field is not empty and contains only numeric data. I was using a regular expression validation control but...
1
by: Kris | last post by:
Hi, I have a DataGrid where in each row has couple of text boxes and an update button. Each row is dynamically generated as the number of rows are not known ahead of time. When the user clicks the...
1
by: Joel Barsotti | last post by:
Is there anything builtin to ASP.net that allows you to tie a text box to a button so when you press enter in the text box it emulates clicking a near by button. I've coded up some client side...
9
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to...
3
by: den | last post by:
inner a text element if I want to allow the insertion of only: alphabet's letters a,b,c,.... and A,B,C,... number and this - and this _ and not want space blank and others characters what is...
2
by: devnew | last post by:
hi i am new to tkinter and would like some help with canvas i am doing validation of contents of a folder and need to show the ok/error messages on a canvas resultdisplay =Canvas(...)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.