Showing posts with label registration form in php using java script. Show all posts
Showing posts with label registration form in php using java script. Show all posts

Monday, 2 September 2013

Java Script validations in php using events


//Java Script validations in php using events

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<script type="text/javascript">
function user()
{
var name=document.form1.name.value;
var namexp=/^[a-zA-Z ]*$/;

if(name=="")
{
document.getElementById("d1").innerHTML="Please Enter Name";
document.form1.name.focus();
return false;
}
else if(!name.match(namexp))
{
document.getElementById("d1").innerHTML="Only letters";
return false;
}

else if(name.length<5)
{document.getElementById("d1").innerHTML="Minimum 5";
document.form1.name.focus();
return false;
}
else
document.getElementById("d1").innerHTML="";
return true;
}


function user1()
{
var mobile=document.form1.mobile.value;
var phexp=/^[0-9]+$/;
if(mobile=="")
{
document.getElementById("d2").innerHTML="Please Enter mobile Number";
document.form1.mobile.focus();
return false;
}
else if(!mobile.match(phexp))
{
document.getElementById("d2").innerHTML="Only Numbers";
return false;
}

else if(mobile.length!=10)
{
document.getElementById("d2").innerHTML="Invalid:Only 10 numbers";
return false;
}
else
document.getElementById("d2").innerHTML="";
return true;
}

function user2()
{
var email=document.form1.email.value;
var atpos=email.indexOf("@");
var dotpos=email.lastIndexOf(".");
if(email=="")
{
document.getElementById("d3").innerHTML="Please Enter email id!";
return false;
}
else if(atpos<1 || dotpos<atpos+2|| dotpos+2>=email.length)
{
document.getElementById("d3").innerHTML="Invalid Email Id";
return false;
}
else
{
document.getElementById("d3").innerHTML="";
return false;
}
}

function user3()
{
if((document.form1.gender[0].checked==false) && (document.form1.gender[1].checked==false))

{
document.getElementById("d4").innerHTML="Please Select Gender !";
return false;
}
else
{
document.getElementById("d4").innerHTML="";
return false;
}}

function user4()
{
var name=document.form1.name.value;
var mobile=document.form1.mobile.value;
var email=document.form1.email.value;
if(name=="")
{
document.getElementById("d1").innerHTML="Please Enter Name";
document.form1.name.focus();
return false;
}
if(mobile==""){
document.getElementById("d2").innerHTML="Please Enter mobile no";
document.form1.mobile.focus();
return false;
}
if(email=="")
{
document.getElementById("d3").innerHTML="Please Enter Email Id";
document.form1.email.focus();
return false;
}
if((document.form1.gender[0].checked==false) && (document.form1.gender[1].checked==false))
{
document.getElementById("d4").innerHTML="Please Select Gender";
document.form1.gender[0].focus();
return false;
}
}
</script>
<form id="form1" name="form1" method="post" action="onblur.php" >
  <table width="1000" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td>&nbsp;</td>
      <td>Name</td>
      <td><input type="text" name="name" id="name" onblur="return user()" onkeyup="return user();" autocomplete="off" /></td>
      <td><div id="d1" style="color:#F00"></div></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>Mobile</td>
      <td><input type="text" name="mobile" id="mobile" onblur="return user1()" onkeyup="return user1()" /></td>
      <td><div id="d2" style="color:#F00"></div></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>Email</td>
      <td><input type="text" name="email" id="email" onblur="return user2()" onkeyup="return user2()" /></td>
      <td><div id="d3" style="color:#F00"></div></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>Gender</td>
      <td>
        <label>
          <input type="radio" name="gender" value="male"  onblur="return user3()" onmouseup="return user3()"/>
          Male</label>
       
        <label>
          <input type="radio" name="gender" value="female" onmouseup="return user3()" />
          Female</label>
        <br />
      </td>
      <td><div id="d4" style="color:#F00"></div></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td><input type="submit" name="submit" id="submit" value="Submit" onclick="return user4()" /></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>
</body>
</html>

Friday, 23 August 2013

Javascript validations in php using functions

//JavaScript Validations in php using onblur, onkeyup functions


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<script type="text/javascript">
function user()
{
var name=document.form1.name.value;
var namexp=/^[a-zA-Z ]*$/;

if(name=="")
{
document.getElementById("d1").innerHTML="Please Enter Name";
document.form1.name.focus();
return false;
}
else if(!name.match(namexp))
{
document.getElementById("d1").innerHTML="Only letters";
return false;
}

else if(name.length<5)
{document.getElementById("d1").innerHTML="Minimum 5";
document.form1.name.focus();
return false;
}
else
document.getElementById("d1").innerHTML="";

}


function user1()
{
var mobile=document.form1.mobile.value;
var phexp=/^[0-9]+$/;
if(mobile=="")
{
document.getElementById("d2").innerHTML="Please Enter mobile Number";
document.form1.mobile.focus();
return false;
}
else if(!mobile.match(phexp))
{
document.getElementById("d2").innerHTML="Only Numbers";
return false;
}

else if(mobile.length!=10)
{
document.getElementById("d2").innerHTML="Invalid:Only 10 numbers";
return false;
}

else
document.getElementById("d2").innerHTML="";

}
</script>
<form id="form1" name="form1" method="post" action="">
  <table width="1000" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="219">&nbsp;</td>
      <td width="70">&nbsp;</td>
      <td width="158">&nbsp;</td>
      <td width="470">&nbsp;</td>
      <td width="40">&nbsp;</td>
      <td width="43">&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>Name</td>
      <td><input type="text" name="name" id="name" onblur="return user()" onkeyup="return user();" autocomplete="off" /></td>
      <td><div id="d1" style="color:#F00"></div></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>Mobile</td>
      <td><input type="text" name="mobile" id="mobile" onblur="return user1()" onkeyup="return user1()" /></td>
      <td><div id="d2" style="color:#F00"></div></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td><input type="submit" name="submit" id="submit" value="Submit" /></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>
</body>
</html>

Tuesday, 9 July 2013

Registration Form in PHP using Java Script Validations

// Registration Form in PHP using Java Script Validations

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<style type="text/css">
.regfirm {
font-size: 20px;
color: #0033FF;
}
.star {
color: #F00;
}
</style></head>

<body>
 <script type="text/javascript">
function uservalid()
{
var name=document.form1.name.value;
var namexp=/^[a-zA-Z ]*$/;
var uid=document.form1.uid.value;
var password=document.form1.pass.value;
var pexpnum=/^(?=.*[0-9])/;
var pexpcap=/^(?=.*[A-Z])/;
var pexpsm=/^(?=.*[a-z])/;
var cpass=document.form1.cpass.value;
var dob=document.form1.dob.value;
var phno=document.form1.mobile.value;
var phexp=/^[0-9]+$/;
var email=document.form1.email.value;
var atpos=email.indexOf("@");
var dotpos=email.lastIndexOf(".");
var address=document.form1.addr.value;
if(name=="")
{
alert("Please Enter Your Name");
document.form1.name.focus();
return false;
}
else if(!name.match(namexp))
{
alert("Please Enter Valid Name");
document.form1.name.focus();
return false;
}
else if(uid=="")
{
alert("Please Enter User Id");
document.form1.uid.focus();
return false;
}
else if(uid.length<5)
{
alert("User Id Minimum 5 letters");
document.form1.uid.focus();
return false;
}

else if(password=="")
{
alert("Please Enter Password");
document.form1.pass.focus();
return false;
}
else if(password.length<6)
{
alert("Password must be more than 6 letters");
document.form1.pass.focus();
return false;
}
else if(!password.match(pexpnum))
{
alert("Password contain atleast one Number");
document.form1.pass.focus();
return false;
}
else if(!password.match(pexpcap))
{
alert("Password contain atleast one Capital letter");
document.form1.pass.focus();
return false;
}
else if(!password.match(pexpsm))
{
alert("Password contain atleast one Small letter");
document.form1.pass.focus();
return false;
}
else if(cpass=="")
{
alert("Please Enter Conform Password");
document.form1.cpass.focus();
return false;
}
else if(password!=cpass)
{
alert("Password and Conform password must be same");
document.form1.cpass.focus();
return false;
}
else if(dob=="")
{
alert("Please Enter Date Of Birth");
document.form1.dob.focus();
return false;
}
else if(phno=="")
{
alert("Please Enter Phone no");
document.form1.mobile.focus();
return false;
}
else if(!phno.match(phexp))
{
alert("Enter Valid Phone no");
document.form1.mobile.focus();
return false;
}
else if(phno.length!=10)
{
alert("Enter 10 digit Phone no");
document.form1.mobile.focus();
return false;
}
else if(email=="")
{
alert("Please Enter Email Id");
document.form1.email.focus();
return false;
}
else if(atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length)
{
alert("Enter Valid Email Id EX: abc@d.com");
document.form1.email.focus();
return false;
}
   else if ( ( document.form1.gender[0].checked == false ) && ( document.form1.gender[1].checked == false ) )
   {
        alert ( "Please choose Your Gender" );
        document.form1.gender[0].focus();
        return false;
    }
else if(address=="")
{
alert("Please Enter Your Full Address");
document.form1.addr.focus();
return false;
}


}
</script>

<table width="562" border="0" align="center" vspace="0px">
  <tr>
    <td>
    <form name="form1" id="form1" method="post" action="" onsubmit="return uservalid()"><table width="500" border="0" align="center">
      <tr>
        <td colspan="2" align="center"><span class="regfirm">Registraion Form</span></td>
      </tr>
      <tr>
        <td width="135">Name <label class="star">*</label></td>
        <td width="234" height="35"><input type="text" name="name" id="name" placeholder="Enter Your Full Name" /></td>
      </tr>
      <tr>
        <td>User Id <label class="star">*</label></td>
        <td height="35"><input type="text" name="uid" id="uid" placeholder="Enter Your User Id" /></td>
        </tr>
      <tr>
        <td>Password <label class="star">*</label></td>
        <td height="35"><input type="password" name="pass" id="pass" placeholder="Create New Password" /></td>
        </tr>
      <tr>
        <td>Conform Password <label class="star">*</label></td>
        <td height="35"><input type="password" name="cpass" id="cpass" placeholder="Enter Same Password " /></td>
        </tr>
      <tr>
        <td>Date Of Birth <label class="star">*</label></td>
        <td height="35"><input type="date" name="dob" id="dob" /></td>
        </tr>
      <tr>
        <td>Contact Number <label class="star">*</label></td>
        <td height="35"><input type="text" name="mobile" id="mobile" placeholder="Enter Your Contact Number" /></td>
        </tr>
      <tr>
        <td>Email Id <label class="star">*</label></td>
        <td height="35"><input type="text" name="email" id="email" placeholder="Enter Your Email Id" /></td>
        </tr>
      <tr>
        <td>Gender <label class="star">*</label></td>
        <td><p>
          <label>
            <input type="radio" name="gender" value="male" />
            Male</label>
          <br />
          <label>
            <input type="radio" name="gender" value="female" />
            Female</label>
          <br />
        </p></td>
        </tr>
      <tr>
        <td>Address <label class="star">*</label></td>
        <td><textarea name="addr" id="addr" cols="25" rows="3" placeholder="Enter Your Full Address" style="resize:none"></textarea></td>
        </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        </tr>
      <tr>
        <td colspan="2"><table width="358" border="0">
          <tr>
            <td width="104">&nbsp;</td>
            <td width="95"><input type="submit" name="submit" id="submit" value="Submit" /></td>
            <td width="103"><input type="reset" name="reset" id="reset" value="Reset" /></td>
            <td width="38">&nbsp;</td>
            </tr>
          </table></td>
      </tr>
      </table>
    </form></td>
  </tr>
  <tr>
  <td height="30" align="center" bgcolor="#3850AF">Copy Rights&copy;Narsi Reddy 2013</td>
  </tr>
</table>
</body>
</html>