You can use the pattern
attribute. The required
attribute is also needed, otherwise an input field with an empty value will be excluded from constraint validation.
<input pattern=".{3,}" required title="3 characters minimum"> <input pattern=".{5,10}" required title="5 to 10 characters">
If you want to create the option to use the pattern for “empty, or minimum length”, you could do the following:
<input pattern=".{0}|.{5,10}" required title="Either 0 OR (5 to 10 chars)"> <input pattern=".{0}|.{8,}" required title="Either 0 OR (8 chars minimum)">
Related Posts:
- How to make a monopoly board using css grid?
- Redirect from an HTML page
- How to horizontally center an element
- Android WebView err_unknown_url_scheme
- How to create an HTML button that acts like a link
- What is the main difference of
and - Why does z-index not work?
- Is it possible to write data to file using only JavaScript?
- Image is not showing in browser?
- Is it possible to write data to file using only JavaScript?
- Adding attribute in jQuery
- Is element block level or inline level?
- XPath //div[contains(text(), ‘string’)] fails to select divs containing ‘string’
- Two divs side by side – Fluid display
- Proper way to make HTML nested list?
- FontAwesome icons are not showing, Why?
- How to create uppercase in pure HTML
- How to change text transparency in HTML/CSS?
- How to put text over images in html?
- How to display PDF file in HTML?
- Add Favicon to Website [duplicate]
- Bootstrap 4 images thumbnail classes
- Multiple radio button groups in one form
- What does the shrink-to-fit viewport meta attribute do?
- What formats can be displayed with type=”application/x-shockwave-flash”
- Placing border inside of div and not on its edge
- How to apply CSS to iframe?
- HTML5 required attribute seems not working
- CSS centred header image
- Relative path in HTML
- How to move text up using CSS when nothing is working
- How to style input and submit button with CSS?
- How to display image with JavaScript?
- How to play a mp3 using Javascript? [duplicate]
- How to outline text in HTML / CSS
- Play videos with iframe in html
- How to call a REST web service API from JavaScript?
- HTML iframe – disable scroll
- How to make HTML table cell editable?
- How to center content in a Bootstrap column?
- HTML5 Validation Error: body start tag seen but an element of the same type was already open
- How do I install a custom font on an HTML site
- Basic CSS – how to overlay a DIV with semi-transparent DIV on top
- difference between width auto and width 100 percent
- Is there a command for formatting HTML in the Atom editor?
- How to show text on image when hovering?
- Is it still valid to use IE=edge,chrome=1?
- Fit background image to div
- Table scroll with HTML and CSS
- Set cellpadding and cellspacing in CSS?
- How to increase height of textarea using bootstrap rows and columns
- Indent List in HTML and CSS
- What’s the difference between using NAV and DIV around Bootstrap 3 navbars?
- Absolute position is not working
- Position absolute but relative to parent
- How do you specify table padding in CSS? ( table, not cell padding )
- Two Divs next to each other, that then stack with responsive change
- link not working
- Generating a Random Number for HTML
- HTML Links are not working
- How to extract svg as file from web page
- Making an image act like a button
- Is it possible to use css to shrink text to automatically fit the size of the div
- HTML5 Canvas Rotate Image
- How can I align text directly beneath an image?
- HTML vs SHTML vs PHTML
- Change background color of iframe issue
- jQuery find element by data attribute value
- WordPress footer menu floating with height of footer
- Keep HTML format when switching from Visual to HTML editor
- Get entire page content (generated HTML in browser)
- Can I force WordPress to use instead of ?
- Will my WordPress site become vulnerable to Cross-Site Scripting (XSS) if I allow img tags in the comments area?
- Add HTML to single post tag
- WordPress “Page not found error” when I edit a page
- How do I put a wordpress blog into my html site?
- New to CMS – WP functionality. overkill or just right?
- how add custom tag/tool in classic editor?
- Attribute Quote Style in WordPress HTML
- Allow HTML in Settings API input field
- Create custom markup to use in posts?
- Widget Text Needs to be White [closed]
- Adding HTML to posts with certain tags?
- Adding to the WYSIWYG
- Redirect WP 404 to html
- How to remove auto generated markup? [closed]
- Is there a common structure for a wordpress formular?
- a generated wordpress page from a form that is inputted by user [closed]
- creates an unnecessary space in content?
- WordPress is replacing code with when I add to posts
- Echo outside HTML
- Add html plugin into wordpress
- WBR tag breaking hyperlinks
- allow html characters on eshop data entry boxes
- Query WordPress Database and Post HTML Table
- theme or plugin or server is outputting html before the init hook fires, how is it possible to prevent this
- How to Know If I’ve Correctly Inserted Alt Attributes Into HTML
- WordPress HTML editor panel is not showing HTML elements
- How to hide unwanted HTML Comment like in website [duplicate]
- Minify HTML on specific page