Form input issue

I added minlength = 3 to my input form.
It’s working fine except user just passing space to fill it up. "AB "

After submitting, the form stored trim string “AB” & passing this to our end which causing the issue

It’s possible to trim the input first on the form before validating?

Use a pattern.

If you add a custom attribute of pattern = /\w+/g
You’re telling the browser “only accept letters, numbers, and underscores, no spaces”
Use that in combination with your min of 3 and you’re all set.

You didn’t specify what characters you want to accept, but you can craft your regex to match pretty much anything you need;

1 Like