Jump to content

<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"/>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...