Validation Code HTML | JavaScript
<?
include 'dbc.php';
?>
<!DOCTYPE html>
<html>
<head>
<style>
form{
margin: 100px;
text-align: center;
font-size: 30px;
}
input{
font-size:20px;
}
</style>
<script>
function TestForm(){
var x=document.forms["form"]["name"].value;
var y=document.forms["form"]["password"].value;
if(x == ""){
alert("Enter your Name");
}
if(y == ""){
alert("Enter your password");
}
return false ;
}
</script>
</head>
<body>
<form action="a.php" method="POST" id="form" >
<fieldset>
<legend>
Your information:
</legend>
<br>
First name:<br>
<input type="text" name="name" onclick="TestForm()" >
<br>
Password :<br>
<input type="password" name="password" onclick="TestForm()" />
<br><br>
<input type="submit" name="submit" value="Submit" >
</fieldset>
</form>
<?php
if(isset($_POST['submit'])){
$name= $_POST['name'];
$password =$_POST['password'];
echo $name;
echo '<br>';
echo $password;
}
?>
</body>
</html>
Comments
Post a Comment