• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

HTML pattern - Regular Expression not working in Dreamweaver and nowhere locally.

Engaged ,
Apr 24, 2023 Apr 24, 2023

Copy link to clipboard

Copied

My pattern in the html form is very simple 

<form>
<input type="text" pattern="[A-Za-z]{2,30}" required>
<!--SEND button bla bla bla...-->
</form>

Why the input still accepts characters like $ ^ % @ #...??? They are VALIDATED like correct, valid characters. I wanted to accepot unicode characters, so I've been implementing the `\p{L}` and similar, so I understabnd that some characters are difficult to restrain or filter but to this `A-Z`, so basic, accepting symbols and numbers??? confusses me. Or DW regex don‘t work at all in local environment? If field is empty I got the client validation of Bootstrap, because I am using Bootstrap utilities too. I have also server side validation. Three pictures attached. 1. If Empty, red message advises me. 2. The wrong characters typed. 3. Correct VALIDATION with the wrong characters, so the PATTERN didn't work. Orientations, please.dw-empty.pngdw-form-input.pngdw-answer.png

TOPICS
Bootstrap , Browser , Code , Error , Other , Product issue

Views

5.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Apr 25, 2023 Apr 25, 2023

FINALLY, at 07:15 in the morning I got this pattern:

pattern="([\p{L}\p{M}]+[\s'‘-]*){2,30}"

dw-validated-unicode.png

This is what I expected, actually. Maybe not 100% perfect. Now I have to see the server side. This is just using the PATTERN attribute. WHAT HAPPENED? I guess that there was a problem with the interface. In the properties, when focussing th INPUT, the PATTERN field was empty even when it was codeed in the HTML (code view). It was surprising for me. I just tried to make the pattern appears in the respective

...

Votes

Translate

Translate
Community Expert ,
Apr 24, 2023 Apr 24, 2023

Copy link to clipboard

Copied

Form valiation won't do anything while you're typing. That's not how HTML5 forms work. 

 

Validation occurs when the form submit button is tapped.  As you can see from this screenshot, the HTML5 form validation works and the pattern attribute does exactly what it's expected to do.

 

image.png

 

Hope that helps.

 

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 24, 2023 Apr 24, 2023

Copy link to clipboard

Copied

I am using Bootstrap and I set «novalidate», because I expect the “nice” validation messages (valid or invalid / green or red feedback from Bootstrap). What you show is the browser validation. I guess that pattern is not so reliable, I will go for pure javascript validation on the client side, let‘s see what happens. Of course, I also have a server side validation, but my concern for now is what happen with the Pattern attribute.

The Bootsrap validation tools allow me to see, yes, if I am typing the right characters, the input border becomes green color as long as the characters are the correct ones. dw-wrong-but-valid.png

This is something wrong. The border should be RED, not green, because the pattern is just [A-Za-z]{2,30}. It confusses me. Ok, I will try full javascript custom validation. Thank U.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2023 Apr 24, 2023

Copy link to clipboard

Copied

With Bootstrap 5 forms, you set the default class of invalid-feedback or valid-feedback . Which class is expressed on your patterned form field? 

See this related link for more details on Bootstrtap 5 form validation: https://getbootstrap.com/docs/5.0/forms/validation/

 

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 24, 2023 Apr 24, 2023

Copy link to clipboard

Copied

dw-form-name-input.png

This is the first block from the begining of the form and the first div containing the text field of the issue (nombre). I added a valid-feedback class.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 25, 2023 Apr 25, 2023

Copy link to clipboard

Copied

LATEST

FINALLY, at 07:15 in the morning I got this pattern:

pattern="([\p{L}\p{M}]+[\s'‘-]*){2,30}"

dw-validated-unicode.png

This is what I expected, actually. Maybe not 100% perfect. Now I have to see the server side. This is just using the PATTERN attribute. WHAT HAPPENED? I guess that there was a problem with the interface. In the properties, when focussing th INPUT, the PATTERN field was empty even when it was codeed in the HTML (code view). It was surprising for me. I just tried to make the pattern appears in the respective field and it worked.

dw-pattern-properties.png

Weird things of the dreamweaver, but I still love it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2023 Apr 24, 2023

Copy link to clipboard

Copied

This will help you out https://formvalidation.io/

Wappler, the only real Dreamweaver alternative.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 24, 2023 Apr 24, 2023

Copy link to clipboard

Copied

Thank U, Mr. Ben. I will check it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines