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/Add add email, phone fields rule in lead form #804

Closed
wants to merge 1 commit into from
Closed

Feat/Add add email, phone fields rule in lead form #804

wants to merge 1 commit into from

Conversation

tommm2
Copy link
Contributor

@tommm2 tommm2 commented Nov 14, 2023

Description

Change leadForm email field and phone field rule

Related Issues

#806

Steps to Test

go to lead page -> click Add new lead button and typing in email, phone fields

Screenshots (if applicable)

If your changes include visual updates, it would be helpful to provide screenshots of the before and after.

Checklist

  • I have tested these changes
  • I have updated the relevant documentation
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the codebase
  • My changes generate no new warnings or errors
  • The title of my pull request is clear and descriptive

rules={[
{
required: true,
pattern: new RegExp(/\d+/g)
Copy link
Contributor Author

@tommm2 tommm2 Nov 14, 2023

Choose a reason for hiding this comment

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

there is another way i try:

<Form.Item
    label={translate('phone')}
    name='phone'
    rules={[
      {
           required: true,
      },
    ]}
    normalize={(value) => value.replace(/\D/g, '')}
>
    <Input type='tel' />
</Form.Item>

it Allows you to enter only numeric strings in the phone field.

Choose a reason for hiding this comment

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

With each national, there is a different pattern. Can you handle it

Copy link
Contributor Author

@tommm2 tommm2 Dec 13, 2023

Choose a reason for hiding this comment

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

maybe we can add a util function like this, It can be used elsewhere.:

 const getPhoneValidationPattern = (lang) => {
    switch (lang) {
      case 'zh-TW':
        return /^[0-9]{10}$/;
      case 'en':
        return /^[0-9]{9}$/;

     // etc...
      default:
        return /\d+/g;
    }
  };

Then I thought that the phone validation message should have an additional "phone_message" in the translation, because the default message is not very user-friendly.
截圖 2023-12-13 11 21 25

@affkjuhyt What do you think?

@tommm2 tommm2 changed the title Add add email, phone fields rule in lead form Feat/Add add email, phone fields rule in lead form Nov 14, 2023
@tommm2 tommm2 closed this by deleting the head repository Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants