Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Dear all
My team leader asked me if there is a possible way to create a user control that takes date values only with the format "dd/MM/yyyy" and prevent any other value or format to be entered (either by keyboard or paste) in this text box; by using VB.NET.
Can you help me please
Posted 17-Dec-11 2:41am
Comments
SAKryukov at 17-Dec-11 23:18pm
   
A vote of 1 by the reason I explained in my comment. Please, play a fair game or find another way to get help.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
fadi77_net at 17-Dec-11 8:27am
   
Guys; I know that, but my team leader do not want to use calender, date time picker, or masked textbox, he want me to create a user control by using textbox to prevent user to enter non date value either by using keyboard or past
OriginalGriff at 17-Dec-11 10:22am
   
If you are using a windows app (as you state in your reply to thatraja's solution, then a Calender is wrong. Use a DateTimePicker instead - it can act like a text box and not show a drop down, but it has two advantages:
1) It displays in tyeh users preferred date format, rather than your team leaders.
2) It means you don't have to do any validation to ensure the user has entered a real date, rather than 99 99 9999, or 31st February.
If your team leader absolutely requires a text box to do this, he is an idiot.
Or this is your homework.
SAKryukov at 17-Dec-11 23:13pm
   
My 5, but not for an answer, for a comment.
This is very inappropriate, when a person not really responsible for a solution asks a question and then impose a limitation referring to some "authority".
 
This is the abuse. Why should we waste time for such question? Let this "team leader" call us, and let OP resolves their problems about relationships by himself.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
v3
Comments
fadi77_net at 17-Dec-11 8:27am
   
Guys; I know that, but my team leader do not want to use calender, date time picker, or masked textbox, he want me to create a user control by using textbox to prevent user to enter non date value either by using keyboard or past
thatraja at 17-Dec-11 8:47am
   
check my updated answer
SAKryukov at 17-Dec-11 23:14pm
   
Please see my comment to the answer by Griff.
--SA
fadi77_net at 17-Dec-11 8:52am
   
Thatraja,I am using windows application, not web application, your updated answer is in java script
thatraja at 17-Dec-11 9:05am
   
check my updated answer again
fadi77_net at 17-Dec-11 11:56am
   
Ok, but in link (How To Disable Right Click In C# Textbox); it is cancelling paste if it fired from the mouse, but what about if (Ctrl + v) or (Shift + Insert) pressed?
thatraja at 17-Dec-11 11:58am
   
What about last 2 links? So you don't want to use Google, right?
:(
fadi77_net at 17-Dec-11 14:27pm
   
No, it is not like what you understand, I searched in google but I did not find any result, I want to check if the value is date value then accept paste, else cancel paste.
paste should be by 3 ways:
1- by mouse
2- by pressing Ctrl + V
3- by pressing Shift + Insert
thatraja at 17-Dec-11 14:32pm
   
OK, from my answer you got solution to disable mouse right clik
Also I gave you links for disabling keypress. Now you need to find implement that based on key code values of keys(ctrl + v & shift + insert). Go ahead.
SAKryukov at 17-Dec-11 23:17pm
   
This discussion does not worth time. This request is totally inappropriate. OP get a reasonable advice about date time picker. If this is not good enough, why negotiating? OP can do whatever they want, but without our help. Let's have some decency.
--SA
thatraja at 17-Dec-11 23:21pm
   
Agree, thats why I gave up after that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 375
1 Sergey Alexandrovich Kryukov 329
2 CPallini 260
3 DamithSL 214
4 Maciej Los 197
0 OriginalGriff 5,455
1 DamithSL 4,457
2 Maciej Los 3,885
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,115


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 12 Feb 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100