close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

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

Thread began 1/28/2020 6:16 am by Nathon Jones Web Design | Last modified 1/29/2020 10:21 pm by Ray Borduin | 44 views | 4 replies |

Nathon Jones Web Design

datepicker field storing all dates to database as 1970-01-01 no matter what user selects?

Can anyone help me decipher why my datepicker field is storing all dates to database as 1970-01-01?

Here's the field....

<input type="text" class="form-control" name="DOB" id="DOB" placeholder="Date of Birth" maxlength="10" value="<?php echo(isset($_GET['v1'])?ValidatedField("healthscreeningform_984","DOB"):$rsEDITFORM->getColumnVal("SMCformDOB")?date("d/m/Y",strtotime($rsEDITFORM->getColumnVal("SMCformDOB"))):"") ?>" required>



Here's the datepicker JS...

<script type="text/javascript">
$(function() {
$( "#DOB" ).datepicker({
dateFormat : 'yy-mm-dd',
changeMonth : true,
changeYear : true,
yearRange: '-100y:c+nn',
maxDate: '-1d'
});
</script>



There are effectively three states this form field can be in....
1) Blank - yet to be filled in by the user
2) Validated value - user has submitted the form, but validation has failed somewhere
3) Recordset value - user is editing the form

The recordset value is converted so that it's displayed in UK format.

Could any of the above be causing this issue?
Hope you can help. Thank you.
NJ

Sign in to reply to this post

Nathon Jones Web Design

WA Server Validation is defaulting the Date of Birth datepicker field to 1970-01-01 when validation fails on any field..

How do we fix this? Link to the form is provided below. If you enter a number in the Name field, validation will fail (so you can check this).

Thank you.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

Please attach the page. I'm away from the office for two weeks so I don't have the ftp connections on my laptop I would normally be able to access.

Sign in to reply to this post
Did this help? Tips are appreciated...

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

Sign in to reply to this post

Ray BorduinWebAssist

I'll need FTP access and a URL to reproduce the issue in order to debug this. The code looks correct to me.

Sign in to reply to this post
Did this help? Tips are appreciated...

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...