close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

datepicker field storing all dates to database as 1/1/70 no matter what user selects?

Thread began 1/28/2020 3:16 am by Nathon Jones Web Design | Last modified 8/12/2020 6:19 pm by Nathon Jones Web Design | 1656 views | 14 replies

Nathon Jones Web Design

I've had to create a hacked solution for this, as the client was at the end of their tether. WA Server Validations definitely does cause the datepicker plugin to revert to 01-01-1970 though, if validation fails.

I created a test page, to make sure I wasn't going mad if nothing else, and the results were the same. I attach that page and if you enter a number in the name field, validation will fail. The date selected will be wiped and replaced with 01-01-1970.

Giving this some serious thought, the problems I'm having will likely be because I need this field to have three separate states. It might be helpful if I explained those in more detail....

1) Blank - when a new user accesses the form then the datepicker field - for date of birth - needs to be blank, ready for the user to select their dob.

2) Validated value - when the form is submitted, and validation fails, the datepicker fields needs to retain the value that the user has entered. As things stand, this is where the value is wiped and replaced with 01-01-1970.

3) Recordset value - once the user has submitted the form, the details are saved to database. The form switches to being an UPDATE behaviour. The datepicker field, therefore, needs to display the date value from recordset.

This ended up being my hack/hatchet job at getting this to work...

<div class="form-group row">
<label for="DOB" class="col-sm-4 col-form-label">Date of Birth</label>
<div class="col-sm-4">

<div class="input-group">
<?php if ($rsEDITFORM->TotalRows == 0) { ?><!-- if new user -->
<input type="text" class="form-control" name="DOB" id="datepicker_1" placeholder="Date of Birth" maxlength="10" value="<?php echo((ValidatedField("healthscreeningform_984","DOB")?ValidatedField("healthscreeningform_984","DOB"):date("d-m-Y"))); ?>" aria-describedby="basic-addon2" required>
<div class="input-group-append" style="cursor: pointer;" onclick="$('#datepicker_1').focus();"><span class="input-group-text" id="basic-addon2"><i class="far fa-calendar"></i></span></div>
<?php } else { ?><!-- if form has been submitted -->
<input type="text" class="form-control" name="DOB" id="datepicker_1" placeholder="Date of Birth" maxlength="10" value="<?php echo($rsEDITFORM->getColumnVal("SMCformDOB")?date("d-m-y",strtotime($rsEDITFORM->getColumnVal("SMCformDOB"))):""); ?>" aria-describedby="basic-addon2" required>
<div class="input-group-append" style="cursor: pointer;" onclick="$('#datepicker_1').focus();"><span class="input-group-text" id="basic-addon2"><i class="far fa-calendar"></i></span></div>
<?php } ?>
</div><!-- /input group -->

</div><!-- /col-sm-4 -->
</div><!-- /form-group row -->



Let me know if you need the database connection script referenced in this page.

I'm also having some issues with duplicate orders on this site - Add to Cart isn't overwriting a product that already exists in the basket, but I'll detail that in a seperate forum post.

Would appreciate your advice on the above.
Thank you.
NJ

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...