...

View Full Version : How !! Javascript generate dynamic date field with date mask "mm/dd/yyy"



korssane
08-19-2011, 03:21 PM
Hi folks,
i am trying to generate a dynamic datefield with date mask "mm/dd/yyyy" and trying to insert it into Oracle db ...i still got the error ORA invalid month ehich means the date filed is not recognized as date:

below is what i am doing :

newStartDate = document.createElement( 'INPUT' ); newStartDate.setAttribute('type','Date'); newStartDate.setAttribute('id1','id'+ elementid+elementrow); newStartDate.setAttribute('name','StartDateName'+ elementid+elementrow); newStartDate.size=8; newStartDate.style.backgroundColor= bgc;

any help thanks ??

Also i want to add a datepicke to this textbox..how it is posible / other option is to use Jquery datepicker but could not know how to impement it

thanks again

venegal
08-19-2011, 06:01 PM
The whole thing sounds rather fishy. If this is about putting something into a database (and not about outputting something to the user), you have to do some sort of server side validation anyway, so why bother with Javascript at all? Even if you used Javascript to provide the right format, that format is merely a "suggestion", which can be easily overridden. If the database requires a certain format, your server side script has to accept every possible input and do the validation and format conversion itself, without choking on a wrong date format.

As for the date picker: You're using the HTML5 date input, and as you surely know, the whole HTML5 thing is rather new. It's the browser's job to provide the input UI for HTML elements, and as of yet, most browsers just don't provide a date picker (Opera does).

You can, of course, use some jQuery date picker, but if you don't know how to implement it, I'm afraid you only got two choices: try to do it anyway and get help if you get stuck, or pay someone to do it for you.

korssane
08-19-2011, 07:21 PM
Hi Venegal
i could do it on the server side with no problem except that my textboxes that holds date are dynamically generated.

I will figure out .

thanks again for the advice.

Old Pedant
08-19-2011, 09:38 PM
Adding javascript to check for the right format wouldn't be hard. That way if the browser doesn't support type="date" you would at least have JS backup.

But you'd need to add it in to your <forn onsubmit> also.

venegal
08-20-2011, 03:32 AM
i could do it on the server side with no problem except that my textboxes that holds date are dynamically generated.


The server side doesn't care whether your field is generated dynamically or has been there in the HTML all along. It just cares about the post data, and won't even know the difference.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum