Email and Form validation using JS Example code

<!DOCTYPE html>
<html>
<head>
<title> NEW YORK FOOD | NIGHTS</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="ico" type="image/jpg" href="img/favicon.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="js/jquery.validationEngine-en.js"></script>
<script>
function validateForm() {
   var x = document.forms["myForm"]["email"].value;

   var reg = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/


      if (!reg.test(x)) {


              $("#demo").css("display","block");


  }

}
</script>

<style type="text/css">

#demo{
display:none;
color:red;
background: #ccc;
}
</style>
</head>
<body>
<header>
<main>
<ul class="logo">
<li class="top">FOURSQUARE</li>
<li>
<select>
<option placeholder="I'm looking for">I'm looking for</option>
</select>
</li>
<li><input id="text" type="email" value="Kakinada "></li>
<li><img class="pic" src="img/search.png"></li>
</ul>
<ul class="button">
<a href="signup.html"><button>Sign Up</button></a>

</ul>
</main>
</header>
<main >
<div class="wrapper">
<form name="myForm" >
<h2>Log in to Foursquare </h2>
<div id="demo" >Email/Phone number You Entered Is Wrong</div>
<div class="box">
<p>
<label>Email or Phone Number:</label>
<input class="box" type="email" name="email" id="email" ><br>

</p>
<p>
<label>Your Password:</label>
<span>(Forgot password?)</span><br><br>
<input class="box" type="password" name="password">
</p>
<input class="login" type="button" value="Log in" onclick="validateForm()">
or<a href="#">Sign up for Foursquare</a>
</form>
</div>
</body>
</main>
</html>

Comments

Popular posts from this blog

Php Form validation with Error messages with Checking fields.

Simple calculator using JQuery and HTML..

how to customize dashboard in active admin gem in rails 4