Prevent Typing On a Date Field

With Formstack for Salesforce, submitters can easily enter dates on a form. However, what if you want to ensure a specific date format? With Javascript, you can ensure date formatting by preventing typing on the field. 

Adding Javascript in Form Settings

While editing your form, click on the Form Settings button. Here, if you scroll down towards the bottom you can see a section called Javascript Code. Place the code listed below in the white box. 

Code to Prevent Typing in the Date Field

function FF_OnAfterRender() {
    $('.hasDatepicker').keydown(function(e) {
   e.preventDefault();
})};


Publishing your Form

Once you have pasted the code, the Form Settings will save automatically. Exit the Form Settings and click "Publish Draft" to publish your form.  Now our users must use the calendar to pick a date!



Was this article helpful?

https://cdn.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete