I am looking to have a time field that starts with 00:00 which is the exact format I want.
As the user types the time I want to read the keystroke and place it within my preassigned value.
–Edit– removed previous validation code which didn’t really pertain to finding out how to validate upon keystroke.
2
Answers
So here is what I found to validate as the user types.
It still shows what they typed before it removes it but it was as close as I could get.
Also if anyone knows a way to pass the parameters in from the eventclick without having to declare them in the function so I can reuse this on multiple fields passing in the different variables would be great!
Basically I setup a session for per user bases that will hold the value of the field when a key is pressed down in memory and when released it will pass the new value through a validation check and if it passes then all good otherwise it resets the value with what is in the memory storage.
Under the program.cs I added
--code
Under the Session Controller
--code
For the webpage view I used the following code --code
Perhaps you use the built in textmode = time.
It not 100% as you ask, but your specification has some "issues".
for example, if I want 10:30, or 1:30?
so, a 1, and a 3 for 10:03 don’t make sense, since I might want:
So, hitting a 1, and then a 3 CAN’T really result in 10:03, since then how would you enter 10:30?
As I stated, you probably best to use the default text mode = time.
It will do MOST of what you ask, does not allow user to enter NON number chars, and formats for most of what you want.
So, say I want 10:30
If I enter 1,0,3, then that’s what I get
e.g., this:
Markup:
So, for 10:30, then 1,0,3
Now, of course above has AM/PM
We just have to try and google, and see if am/pm can be removed.
And if you need more then 12 hours, then again, the above may well not help you.