Jump to content

How to change html type for Form Field

Recommended Posts

On the contact form on this page, I am wanting to change the html type of the 'date' field.

 

Here is the desired change:

Original:

<input class="field-element text" type="text" id="text-yui_3_17_2_1_1541027265450_300449-field">

Desired:

<input class="field-element text" type="date" id="text-yui_3_17_2_1_1541027265450_300449-field">

 

Could someone help me know what custom html to inject into the page's header?

Link to comment
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

59 minutes ago, Wazza said:

On the contact form on this page, I am wanting to change the html type of the 'date' field.

 

Here is the desired change:

Original:

<input class="field-element text" type="text" id="text-yui_3_17_2_1_1541027265450_300449-field">

Desired:

<input class="field-element text" type="date" id="text-yui_3_17_2_1_1541027265450_300449-field">

 

Could someone help me know what custom html to inject into the page's header?

In order change attribute of HTML, you need javascript which is only available on Business Plan/ higher one. What is the final result you want to achieve?

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Keyword Highlighter
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment

I have business plan, so just after help with what javascript code to use.

The intended result is to have the html type for the form field be date, so that web browsers can allow the date picker for data input. (See attached screenshot showing how this would look!)

+++

The idea was inspired by zoxoxu's post on the following thread. But the code I haven't been able to get working.

Here is what I have tried injecting into the header of the page:

<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>

<script>

  $( document ).ready(function() {

    $('#text-yui_3_17_2_1_1541027265450_300449-field').attr("type", "date");

});

</script>

 

 

Screen Shot 2022-11-14 at 3.21.00 pm.png

Link to comment
12 minutes ago, Wazza said:

I have business plan, so just after help with what javascript code to use.

The intended result is to have the html type for the form field be date, so that web browsers can allow the date picker for data input. (See attached screenshot showing how this would look!)

+++

The idea was inspired by zoxoxu's post on the following thread. But the code I haven't been able to get working.

Here is what I have tried injecting into the header of the page:

<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>

<script>

  $( document ).ready(function() {

    $('#text-yui_3_17_2_1_1541027265450_300449-field').attr("type", "date");

});

</script>

 

 

Screen Shot 2022-11-14 at 3.21.00 pm.png

So you have figured it out, right?

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Keyword Highlighter
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment

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.