Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2011
    Posts
    148
    Thanks
    18
    Thanked 0 Times in 0 Posts

    How !! Javascript generate dynamic date field with date mask "mm/dd/yyy"

    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

  • #2
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Jun 2011
    Posts
    148
    Thanks
    18
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    Quote Originally Posted by korssane View Post
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •