Form Validation in Java Script:

Form Validation in Java Script:

Form Validation in Java Script:

HTML 5 adds some attributes that allow form validation.

Example: the required attribute can be added to an input field to make it mandatory to fill in.

The form element has an onsubmit event that can be handled to perform validation.

<form onsubmit = “return validate()” method = “post”>

Number: <input type = “text” name = “num1″id = “num1″/>

<br/>

Repeat: <input type = “text” name=”num2″ id = “num2″/>

<br/>

<input type = “submit” value = “submit”/>

</form>

Validation with JavaScript:

function validate

var n1 = document.getElementById(“num1”);

var n2 = document.getElementById(“num2”);

if(n1.value != ” ” && n2.value != “”){

if(n1.value == n2.value){

return true;

}

}

alert(the values should be equal and not blank”);

return false;

}

Website | + posts

Technical content writer with data scientist, artificial intelligence, programming language, database. He has a bachelor’s degree in IT and a certificate in digital marketing, Digital transformation web development android app development He has written for website like Boomi techie, tech mantra, information hub, Tech all

amit verma

Technical content writer with data scientist, artificial intelligence, programming language, database. He has a bachelor’s degree in IT and a certificate in digital marketing, Digital transformation web development android app development He has written for website like Boomi techie, tech mantra, information hub, Tech all