Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Millipede Posted September 27, 2018 Posted September 27, 2018 How can you stop someone entering a space or single character (eg, a full stop) as a means of avoiding completing required information in a text field? There’s an option for Maximum Length but not for minimum?
Millipede Posted November 8, 2018 Author Posted November 8, 2018 Am I the only one who's experienced new members avoiding filling in a required profile field by entering a single character or a space, or is there really no solution to this? I don't know regex, but if someone might what the regex might be to force a minimum number of characters in a profile text field, I'd be very grateful!
Aiwa Posted November 8, 2018 Posted November 8, 2018 (\w+?){2} roughly equates to searching for at least (1) 2 character word, with no spaces between the characters. Test it with your expected data sets first, depending on the data set YMMV. https://regex101.com/r/cO8lqs/4
Millipede Posted November 8, 2018 Author Posted November 8, 2018 I only know a really tiny bit of regex. I forgot the profile fields have an option to enter regex to check the value entered, hence my question. Testing it on the link you gave, it works great, thanks so much! I've got a few regex sites bookmarked, but hadn't seen that page before, so thanks for that too.
Millipede Posted November 14, 2018 Author Posted November 14, 2018 A tip for anyone trying this. When I tried entering: (\w+?){4} as I want a minimum of 1 word containing 4 characters, I was met with a “That value is not allowed” message, despite knowing it should work. Some searching on this forum indicated that I might need to add a "/" in front of and at end of the regex, eg: /(\w+?){4}/ I tried that and it then worked. My only quibble with this is the phrase “That value is not allowed”, which is shown to members if they try to leave the field empty or enter a full-stop, etc. They won't understand what's meant by "value". I can't change (translate) it in languages, as that term is used for all sorts else that's related to various "forms".
Millipede Posted November 25, 2018 Author Posted November 25, 2018 Hmmm... it didn't work... I have 2 profile fields that are required during registration. Somebody registered today and entered 2 characters and it was accepted. I don't know why the regex is now not working, as it worked before when I tested it myself as a guest pretending to register. Any ideas, please?
Aiwa Posted November 25, 2018 Posted November 25, 2018 What's the specific value? Are you certain there aren't non breaking invisible characters? Can you link to the user's profile?
Millipede Posted November 25, 2018 Author Posted November 25, 2018 There are no non-breaking or any other invisible characters. I've no problem linking to the user's profile, they've successfully registered. The values are the ones mentioned earlier in this topic. I tried it again as a guest pretending to register. The regex works fine for the first one, but not for the second one. This is the first field: This is the 2nd field: The difference between the two is that one is a "Text" type with a limit of 150 characters and the other is a "Text Area" type with a higher character limit. The member entered a 4 character word for the 1st field, and entered "N/A" for the 2nd one. But, like I said, when I first did these and tested them, they both worked fine. So I don't understand why the 2nd one now doesn't and even allows it to be blank; it's acting as if it weren't required?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.