Jump to content
  • 0

Not allow a date in the future from being selected from date/time field type


DavidKennett

Question

Following on from the below post 

 I have the same issue where i have implemented the below script but it is still allowing me to select a date in the future from the date/time.

 

<script>
function pastDateValidation()
{
    var d=document.getElementById("InsertRecordClient_AML_Date").value;
        if(new Date(d) > new Date())
    {
        alert("Select a date which is before now");
        document.getElementById("InsertRecordClient_AML_Date").value="";
    }

}
document.getElementById('InsertRecordClient_AML_Date').onchange = pastDateValidation;

</script>

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0
On 11/17/2017 at 2:42 PM, DavidKennett said:

Following on from the below post 

 I have the same issue where i have implemented the below script but it is still allowing me to select a date in the future from the date/time.

 

<script>
function pastDateValidation()
{
    var d=document.getElementById("InsertRecordClient_AML_Date").value;
        if(new Date(d) > new Date())
    {
        alert("Select a date which is before now");
        document.getElementById("InsertRecordClient_AML_Date").value="";
    }

}
document.getElementById('InsertRecordClient_AML_Date').onchange = pastDateValidation;

</script>

Hi, I tried this code, it works for me.

I would recommend checking that:

- you specified correct fieldname in the code;

- code is inserted into the footer of the datapage and your datapage is a submission form;

- there is no errors in browser's console (hit F12 and select Console tab)

Link to comment
Share on other sites

  • 0

Thank you for the reply. I have checked those three things and still am allowed to enter a date in the future using the time/date field type. 

 

I've been by support that because i'm in UK localization the script may need changing. It works in US localization. Would you know what i would need to change for it to work in UK localization please?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...