I need a format for a textbox in html that is MM/DD, how do I do it?

I need a format for a textbox in html that is MM/DD, how do I do it?
cbruneAsked:
Who is Participating?
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
This seems to work
http://jsbin.com/fawitutagi/1/edit?html,output
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
  <meta charset="utf-8">
  <script>
    $(function(){
$('.mmdd').focusout (function(){
  var dt = $(this).val();
  var arrDt = dt.split('/');
  var m = "0"+parseInt(arrDt[0], 10);
  var d = "0"+parseInt(arrDt[1], 10);
 
  $(this).val( m.substr(m.length - 2)+'/'+ m.substr(m.length - 2));
  
});
});


    
  </script>
  <title>JS Bin</title>
</head>
<body>
<input class="mmdd"><input>
</body>
</html>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.