Jump to content

Changing date form input type from "text" to "number"

Recommended Posts

HTML forms have a type of input called date that come by default with a date picker, you can't change the type with squarespace but you can override it. Not all the old version of browsers will support this form input - link

  1. Create a normal txt input on your form
  2. copy the id of the input field (through right click -> inspect)
  3. open the settings of the page then advanced
  4. paste the follow code and replace YOUR-ID with the ID you copied
<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
<script>
  $( document ).ready(function() {
    $('#YOUR-ID').attr("type", "date");
	});
</script>

same with number field and others...

A shame that Squarespace doesn't use the correct type for their forms, number should be input type="number" instead of type="text"...

Link to comment
  • Replies 0
  • Views 555
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.