Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added realtime client side validation on checkout form inputs #27

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Ankesh2004
Copy link

Type of Change

  • Enhancement

Description

Adds realtime input validations on checkout page.

Additional Changes

  • Creates checkout-validation.js in js folder.
  • Adds above script in hyperswitch-checkout.php

Motivation and Context

Fixes issue juspay/hyperswitch#6169

How did you test it?

Locally tested
image

@sakksham7
Copy link

Hey @Ankesh2004 can you please add a screen recording of how validations will work covering all edge cases along with the screenshot you have provided.

@gorakhnathy7
Copy link
Collaborator

Hey @Ankesh2004 Any updates.

);
}
}
add_action('wp_enqueue_scripts', 'enqueue_checkout_validation_script');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
add_action('wp_enqueue_scripts', 'enqueue_checkout_validation_script');
add_action( 'wp_enqueue_scripts', 'enqueue_checkout_validation_script' );

console.error('Place Order button not found');
return;
}
console.log('Place Order button found');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log('Place Order button found');

Comment on lines +5 to +14
if (!form) {
console.error('Checkout form not found');
return;
}
console.log('Checkout form found');

if (!placeOrderButton) {
console.error('Place Order button not found');
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!form) {
console.error('Checkout form not found');
return;
}
console.log('Checkout form found');
if (!placeOrderButton) {
console.error('Place Order button not found');
return;
}

Comment on lines +26 to +29
if (!emailField || !firstNameField || !lastNameField || !zipCodeField || !phoneField) {
console.error('One or more form fields not found');
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!emailField || !firstNameField || !lastNameField || !zipCodeField || !phoneField) {
console.error('One or more form fields not found');
return;
}

@vsrivatsa-edinburgh
Copy link
Member

This is good work
I'm wondering how to solve this without using hardcoded error messages. Does WC expose any functions on their scripts that can be used to spit out respective error messages - that way you wouldn't have to worry about error messages in other languages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants