Prevent Typing On a Date Field With Javascript

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) {





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?
1 out of 1 found this helpful



Article is closed for comments.