ThomasTJdev / nim_websitecreator

Nim fullstack website framework - deploy a website within minutes
https://nimwc.org
MIT License
176 stars 7 forks source link

User specific HTML pattern for <input> fields #99

Closed ThomasTJdev closed 5 years ago

ThomasTJdev commented 5 years ago

Currenty we have hardcoded patterns for html where we require {ASCII}. This prevents me from using Danish letters such as æøå. When I delete the pattern, I have no problem with saving the Danish letters, and they are rendered fine.

Proposal:

  1. Let user specify a custom pattern in config.cfg which will be used.
  2. Only keep pattern to verify the length and ignore the characters (this can be done with min and max)

What do you think @juancarlospaco ?


Hardcoded patterns:

<input type="text" class="input" name="title" id="title" required value="${page[4]}" style="width: 300px;" dir="auto" pattern="^[\p{ASCII}]{1,99}$$" onblur="this.value=this.value.replace(/\s\s+/g, ' ').replace(/^\s+|\s+$$/g, '')"/>
----
<input class="input" type="text" id="name" name="name" minlength="2" maxlength="128" placeholder="Type Name for new Page" required value="${page[7]}" dir="auto" pattern="^[\p{ASCII}]{2,128}$$" onblur="this.value=this.value.replace(/\s\s+/g, ' ').replace(/^\s+|\s+$$/g, '')">
----
<input class="input" type="text" name="category" value="${category}" placeholder="Single word category" dir="auto" pattern="^[\p{ASCII}]{2,99}$$" onblur="this.value=this.value.replace(/\s\s+/g, ' ').replace(/^\s+|\s+$$/g, '')">
juancarlospaco commented 5 years ago

That can be a good addition to HTML-Tools via Pull Request.

Maybe it can have some const with patterns for different levels of strictness, like: ASCII :arrow_right: Unicode but not Emoji :arrow_right: Unicode but not weird stuff :arrow_right: Unicode unfiltered

Then you just $HtmlPatternFoo or $HtmlPatternBar

Then we DRY, and is reusable on Nim backend code too.

Changing the min and max lengh to min and max is the best whatsoever and removing it from patterns.

:thinking: