Current location: Hot Scripts Forums » General Web Coding » JavaScript » Javascript d.o.b help


Javascript d.o.b help

Reply
  #1 (permalink)  
Old 11-08-11, 08:15 AM
Kamboodle Kamboodle is offline
New Member
 
Join Date: Mar 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Javascript d.o.b help

Hi there,

I was just wondering if it is possible to change this to the British format of dd/mm/yyyy

At present its mm/dd/yyyy but if I put day first it's blank because the month hasn't been selected. Would it be possible to change it so that the day is 31 by default and if it dosent match the month i.e 28 days in feb it will display an error?

Many thanks

Code:
<script language="JavaScript" type="text/javascript">
function changeDate(i){
var e = document.getElementById('day');
while(e.length>0)
e.remove(e.length-1);
var j=-1;
if(i=="na")
k=0;
else if(i==2)
k=28;
else if(i==4||i==6||i==9||i==11)
k=30;
else
k=31;
while(j++<k){
var s=document.createElement('option');
var e=document.getElementById('day');
if(j==0){
s.text="Day";
s.value="na";
try{
e.add(s,null);}
catch(ex){
e.add(s);}}
else{
s.text=j;
s.value=j;
try{
e.add(s,null);}
catch(ex){
e.add(s);}}}}
y = 1988;
while (y-->1909){
var s = document.createElement('option');
var e = document.getElementById('year');
s.text=y;
s.value=y;
try{
e.add(s,null);}
catch(ex){
e.add(s);}}
</script>
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Senior JavaScript Developer - Full Time - Permanent - London AJAX, CSS, JSONP Chris Peacock Job Offers & Assistance 0 01-19-10 12:28 PM
Add javascript after load? <?Wille?> JavaScript 14 03-31-06 04:52 AM
Reaaly stuck about javascript over frames muratisik JavaScript 1 12-14-03 11:58 AM


All times are GMT -5. The time now is 02:08 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.