Not sure whether to ask this in the MVC or te AJAX forum, but here goes. Following Stephen Walther's great blog entries (Tip #36 and #37) on how to use the Script Versions of the Ajax toolkit with MVC I have managed to get the masked edit extender working
in the same way. My problem is I am not sure how best to use it to give me the result I need.
Basically I am trying to create a simple time recording system and I have created a simple MVC application to do this. The idea is time is entered in the format 99:99 i.e. hours and minutes worked. The data itelf will be stored in an integer (total minutes
in effect). I can set a mask to be 99-99 and when the user clicks in the field the - is displayed. The 2 problems I have are I want this formating to to remain after the user leaves the field, at the moment the - disappears. And secondly how can I ensure
that the time entered is valied, for example the first digit cannot be more than 2; if the first digit is 2 then the second digit cannot be more than 4; and the third digit cannot be more than 5.
Is there a good way to use the masked edit control in MVC to do this, or am I going about this all the wrong way; maybe I need to use regular expressions for this. Or maybe I should use to fields one for the hours and one for the minutes and combine them?
Apologies if this is a really obvious thing, I am still very much a noob with all this stuff.
Qweeg
Member
3 Points
7 Posts
Masked Edit for time entry
Jun 08, 2009 10:11 AM|LINK
Hi all,
Not sure whether to ask this in the MVC or te AJAX forum, but here goes. Following Stephen Walther's great blog entries (Tip #36 and #37) on how to use the Script Versions of the Ajax toolkit with MVC I have managed to get the masked edit extender working in the same way. My problem is I am not sure how best to use it to give me the result I need.
Basically I am trying to create a simple time recording system and I have created a simple MVC application to do this. The idea is time is entered in the format 99:99 i.e. hours and minutes worked. The data itelf will be stored in an integer (total minutes in effect). I can set a mask to be 99-99 and when the user clicks in the field the - is displayed. The 2 problems I have are I want this formating to to remain after the user leaves the field, at the moment the - disappears. And secondly how can I ensure that the time entered is valied, for example the first digit cannot be more than 2; if the first digit is 2 then the second digit cannot be more than 4; and the third digit cannot be more than 5.
Is there a good way to use the masked edit control in MVC to do this, or am I going about this all the wrong way; maybe I need to use regular expressions for this. Or maybe I should use to fields one for the hours and one for the minutes and combine them?
Apologies if this is a really obvious thing, I am still very much a noob with all this stuff.
Pikesville P...
Participant
1036 Points
197 Posts
Re: Masked Edit for time entry
Sep 10, 2009 01:26 AM|LINK
Never shoot a cannon at a rabbit.
Never use AJAX when you can use JQuery.
You''ll pick it up very fast
and odds are there's a plug in already: http://digitalbush.com/projects/masked-input-plugin/
You haven't had a beer until you've learned how to make your own...