App reviews, troubleshooting, and recommendations
Hello,
On product page, I have "upload file" field and "note" field (It's custom field.), They are required field.
I use getElementsByClassName("shopify-payment-button__button") and add onclick by javascript
for validate 2 fields ("upload file" field and "note" field).
I use preventDefault() and stopImmediatePropagation()
It is not work, I cannot stop for go to checkout page.
What do I do validate "upload file" field and "note" field before before "buy it now" button works ?
Solved! Go to the solution
This is an accepted solution.
I cannot validate for "buy it now" button.
before when I upload file, I hide "buy it now" button
After upload success, I show "buy it now" button
Hi,
1. For file input create,
<input type="file" id="file" />
2. Inside script tag create function
function ValidateFileInput() {
var fileInput = document.getElementById('file');
along with this you need to check file(allowed extensions like .jpg, .jepg, .png, etc)
3.
<input type="text" name="firstname" id="firstname" />
Check validation for,
var fname = document.getElementById('firstname');
if (fileInput.file && fname) {
// Your code goes here
} // clsoe if statement
} // function
4. Buy Now button
onclick="return ValidateFileInput()"
where to paste this code . i tried to pace this code in poduct.liquid buy it is not working pls help to slove this . for my custom field i need to validate for buy it now button
This is an accepted solution.
I cannot validate for "buy it now" button.
before when I upload file, I hide "buy it now" button
After upload success, I show "buy it now" button
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025