[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

DATE INPUT MASK TEXT FIELD MM/DD/YYYY

Posted on 2001-08-29
10
Medium Priority
?
691 Views
Last Modified: 2011-09-20
Hello I need to know how to put a input mask so when the user types onkeydown the format comes out __/__/____.  I don't want to split the boxes right now because I have alot of validation already for date but the user has to type slashes.
0
Comment
Question by:InvisibleMan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 8

Expert Comment

by:bebonham
ID: 6437173
fun

<SCRIPT>

function handleKey(e)
{
chco= (document.layers) ? e.which : event.keyCode;
key = String.fromCharCode(chco)
d=document.forms[0].date
d.value=d.value.replace(/_/,key)
}


</SCRIPT>

<FORM>
<INPUT TYPE="TEXT" NAME="date" value="__/__/____" MAXLENGTH="10" ONFOCUS="document.onkeypress=handleKey" ONBLUR="document.onkeypress=null">
</FORM>
0
 

Author Comment

by:InvisibleMan
ID: 6437450
I cant have that value in the textbox because I am pulling a value in some cases from the database so value="<%=datep%>"
0
 

Author Comment

by:InvisibleMan
ID: 6437452
I cant have that value in the textbox because I am pulling a value in some cases from the database so value="<%=datep%>"
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 15

Accepted Solution

by:
a.marsh earned 100 total points
ID: 6437667
Whenever I do this I always use three separate textboxes - make it much easier.

And if you are unable to alter any of the server-side scripting that interacts with the database etc., then you should be able to manipulate things with javascript.

I'll put an example together for you.

:o)

Ant
0
 

Author Comment

by:InvisibleMan
ID: 6438540
a marsh I can't use 3boxes there is already validation with the box as it is and the users dont want that.
0
 
LVL 8

Expert Comment

by:bebonham
ID: 6438625
try this:

<SCRIPT>
var i=0
function handleKey(e)
{
chco= (document.layers) ? e.which : event.keyCode;
key = String.fromCharCode(chco)
d=document.forms[0].date
if(d.value.length>=10){
return false
}
ld=d.value.split("")
ld[i]=key
i++
d.value=ld.join("")
if(i==2 || i==5){
ld[i]='/'
i++
d.value=ld.join("")
}
return false
}



</SCRIPT>

<FORM>
<INPUT TYPE="TEXT" NAME="date" ONKEYPRESS="return handleKey()" MAXLENGTH="10">
</FORM>
0
 

Author Comment

by:InvisibleMan
ID: 6442167
bebonham still is not working it jumbles things up and doesnt even let me type anything most times.
0
 
LVL 8

Expert Comment

by:bebonham
ID: 6442439
yeah, it'll do that in netscape, it works perfectly in ie though.


this is the best it is going to get unless you use 3 fields...

I suggest you use browser sniffing and use this only for ie..

which is over 80% of all people...


0
 
LVL 8

Expert Comment

by:bebonham
ID: 6449267
either that or reject my answer and accept someone elses, but I don't think anything else needs to be said, unless you are having problems with my script in ie, or you decide to use 3 boxes.
0
 
LVL 2

Expert Comment

by:Lunchy
ID: 6648555
InvisibleMan please either:

1. Award the question to an expert
2. Request points refunded for no answer

Do not accept this comment as an answer!

Lunchy
Friendly Neighbourhood Community Support Moderator
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question