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