Koral Levi
Koral Levi

Reputation: 1

Shopify-.liquid file: how can I add a js validation (with onsubmit which I have) to exist form?

Here is the form tag which I want to add validation to:

{% form 'customer_address', customer.new_address %}

<div>
<input type="submit" class="btn" value="{{ 'customer.addresses.add' | t }}" />
</div>

{% endform %}

Upvotes: 0

Views: 1843

Answers (1)

Juandres Yepes Narvaez
Juandres Yepes Narvaez

Reputation: 163

The {% form 'customer_address', customer.new_address %} return an HTML form:

<form method="post" action="/account/addresses" id="address_form_new" accept-charset="UTF-8">

so you could use the id #address_form_new or the action attribute: [action="/account/addresses"]

$('#address_form_new').on('submit', function(e) {
// Your validation
});

Upvotes: 1

Related Questions