control date format in form field?

P

pete0085

I have some form fields where users can enter in a date. In this field, is
there a way I can control the date format they can enter? Lets say I only
want them to use dd/mm/yyyy and don't want to use June 08 2009 for example.

I don't want the current date entered.

Let me know if this is a html code inside the form that will accomplish this.
 
R

Ronx

Split the date into three fields: day, month and year - using select fields
will eliminate some invalid dates.
On the server, if you are using asp, PHP or asp.NET you can join the fields
in the corect format. If you are using FP extensions to process the form,
then the joining must be done (if at all) in JavaScript when the form is
submitted - the result being the value for a hidden field.

--
Ron Symonds
Microsoft MVP (Expression)
http://www.rxs-enterprises.org/fp

Reply only to group - emails will be deleted unread.
 
P

pete0085

There isn't database. It's more of a static single html page that is being
imported into another application.

How would I split the date into 3 fields? The way it currently set up is
having a single form field box where you can enter in the date.
 
R

Ronx

Instead of (for example)
<p>Date: <input type="text" name="datefield"></p>
use

<form action="whatever" method="post"
onsubmit="this.datefield.value=this.df.value + '/' +this.mf.value + '/' +
this.yf.value">

<p>Day: <input type="text" name="df">
Month: <input type="text" name="mf">
Year: <input type="text" name="yf">
<input type="hidden" value="" name="datefield"></p>


</form>

The fields need validation to ensure the date is valid.

Change the value for action in the form tag to that required, and change the
name of datefield everywhere to the name you use.
A working example is at http://www.rxs-enterprises.org/tests/pages/day.asp
--
Ron Symonds
Microsoft MVP (Expression)
http://www.rxs-enterprises.org/fp

Reply only to group - emails will be deleted unread.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top