How to check form validation by javascript

Now, I am ready to show how to check form validation by using javascript. Its a primary stage of a javascript prorgammer. Lets go-

<!DOCTYPE html>
<title>Learn JavaScrtipt</title>


var x = window.confirm(“Are you sure to delete this?”);


window.alert(“Your data is goting to delete.”);


window.location = “;;


function emailchk(){
var x =;

if(x.indexOf(“@”) == -1){
alert(“Please entair a valid email address”);
function validation(){

alert (“Please enter User Name”);
return false;


<form name=”formname” method=”POST” onsubmit=”return validation()”>
<input type=”text” name=”name” value=”” placeholder=”Type your name” ><br/>
<input type=”text” name=”email” value=”” placeholder=”Type your email” ><br/>
<input type=”submit” name=”email” value=”Submit Now”>

Save this file and run it. It will check if any field will be blank. Thanks for reading.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s