Jump to content
Sign in to follow this  

<input required>

Recommended Posts

For that you'll need Javascript.

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8"/>
window.onerror = function(a,b,c){
alert('Javascript Error: '+a+'\nFile: '+b+'\nLine: '+c);
return true;
'use strict';

function validateForm(evt){
var txt = document.getElementById('txt1').value.trim();
if (txt.length < 8){
alert('Submission Aborted\nText is only ' + txt.length + ' characters');

window.onload = function(){
document.getElementById('form1').onsubmit = validateForm;



<form id="form1">
<input type="text" name="txt1" id="txt1"/>
<input type="submit" value="Submit"/>


Share this post

Link to post
Share on other sites

You can use the pattern attribute:

<input required pattern="\s*\S{8,}\s*">

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...