Need SIMPLE Datepicker in Javascript

Hello,

I have a form that needs to have ten dates entered.  I would like to have a SIMPLE script that could be made to have the end use enter a valid date.  Most like JavaScript would be better for this app.

Thanks!
Scott
IRHuskerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

guru_samiCommented:
0
HonorGodSoftware EngineerCommented:
Please define "valid" dates

- Must they be in a specific order?
- Must they be specific days of the week?
- Are holidays allowed?
- Is there a specific ranges for these valid dates?

http://www.experts-exchange.com/articles/Programming/Languages/Scripting/JavaScript/Can-I-have-a-date.html
0
IRHuskerAuthor Commented:
By valid I mean in something like the mm/dd/yyyy format to be inserted into SQL.

Thanks!
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

remorinaCommented:
Hi IRHusker,
You can try the jquery ui datepicker and adjust the date format, local, etcc.

I've attached an example below which uses the datepicker and inserts the date with your required format


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>jQuery UI - Datepicker</title>
	<link rel="stylesheet" href="http://jquery-ui.googlecode.com/svn/tags/latest/themes/base/jquery-ui.css" type="text/css" media="all" />
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
	<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type="text/javascript"></script>
    <style type="text/css">
        body {font:normal 12px Arial, Helvetica, Serif;}
    </style>
</head>

<body>
    <script type="text/javascript">
	$(function() {
		$("#datepicker").datepicker();
		$.datepicker.setDefaults($.datepicker.regional['']); 
		$.datepicker.formatDate('mm-dd-yyyy');
	});
    </script>
    <div class="demo">
        <p>
            Date:
            <input type="text" id="datepicker" />
        </p>
    </div>
    <div>
        <p>
            The datepicker is tied to a standard form input field. Focus on the input (click,
            or use the tab key) to open an interactive calendar in a small overlay. Choose a
            date, click elsewhere on the page (blur the input), or hit the Esc key to close.
            If a date is chosen, feedback is shown as the input's value.</p>
    </div>
</body>
</html>

Open in new window

jquery-date-picker.htm
0
HonorGodSoftware EngineerCommented:
Something like this perhaps?
<!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<title> Date Validation </title>
<head>
<script type='text/javascript'>
  function D2( val ) {
    return ( val < 10 ) ? '0' + val : val;
  }

  function valiDate( date ) {
    var before = date.toString();
    if ( before.match( /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/ ) ) {
      var after = new Date( RegExp.$3, RegExp.$1, RegExp.$2 );
      before = D2( RegExp.$1 ) + '/' + D2( RegExp.$2 ) + '/' + RegExp.$3;
      var after = D2( date.getMonth() ) + '/' + D2( date.getDate() ) + '/' + date.getFullYear();
      if ( before == after )
        return true;
    }
    alert( 'Invalid date: ' + before );
    return false;
  }

</script>
</head>
<body>
  <input type='text' value='mm/dd/yyyy' onchange='valiDate(this.value)'>
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IRHuskerAuthor Commented:
Thanks!
0
HonorGodSoftware EngineerCommented:
You are very welcome.

Thanks for the grade & points.

Good luck & have a great day.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.