Вы находитесь на странице: 1из 6

function validate_form() { if(document.login.fname.value=="" { document.login.fname.

value==null)

alert("enter your firstname"); document.login.fname.focus(); return false; } if(document.login.lname.value=="" { alert("enter your lastname"); document.login.lname.focus(); return false; } if ((document.login.email.value == "" { alert("enter your email"); document.login.email.focus(); return false; } if(document.login.password.value=="" { alert("enter your password"); document.login.password.focus(); return false; } if(document.login.cpassword.value==!document.login.password.value) { alert("enter your confirmpassword"); document.login.cpassword.focus(); return false; } document.login.password.value==null) document.login.email.value.indexOf('@', 0) == -1) document.login.lname.value==null)

if(document.login.age.value=="unselect") { alert("select your age"); document.login.age.focus(); return false;

} //date validation var dtCh= "/"; var minYear=1900; var maxYear=2100; function isInteger(s) { var i; for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (((c < "0") (c > "9"))) return false; } } function stripCharsInBag(s, bag) { var i; var returnString = ""; for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (bag.indexOf(c) == -1) returnString += c; } return returnString; } function daysInFebruary (year) { // February has 29 days in any year // EXCEPT for centurial years which are return (((year % 4 == 0) && ( (!(year % } function DaysArray(n) { for (var i = 1; i <= n; i++) { this[i] = 31 if (i==4 i==6 i==9 { this[i] = 30 } if (i==2) { this[i] = 29 } } return this } function isDate(dtStr) { var daysInMonth = DaysArray(12) var pos1=dtStr.indexOf(dtCh) var pos2=dtStr.indexOf(dtCh,pos1+1)

evenly divisible by four, not also divisible by 400. 100 == 0)) (year % 400 == 0))) ? 29 : 28 );

i==11)

var strMonth=dtStr.substring(0,pos1) var strDay=dtStr.substring(pos1+1,pos2) var strYear=dtStr.substring(pos2+1) strYr=strYear if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1) if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1) for (var i = 1; i <= 3; i++) { if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1) } day=parseInt(strDay) month=parseInt(strMonth) year=parseInt(strYr) if (pos1==-1 pos2==-1) { alert("The date format should be : mm/dd/yyyy") return false } if (strMonth.length<1 month<1 month>12) { alert("Please enter a valid month") return false } if (strDay.length<1 day<1 day>31 (month==2 && day>daysInFebruary(year)) { alert("Please enter a valid day") return false } if (strYear.length != 4 year==0 year<minYear year>maxYear) { alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear) return false } if (dtStr.indexOf(dtCh,pos2+1)!=-1 isInteger(stripCharsInBag(dtStr, dtCh))==fals { alert("Please enter a valid date") return false } return true } if (isDate(document.login.dob.value)==false) { document.login.dob.focus() return false }

if ( ( document.login.gender[0].checked == false ) && ( document.login.gender[1].checked == { alert ( "Please choose your Gender: Male or Female" ); return false; } if ( document.login.age.selectedIndex == 0 ) { alert ( "Please select your Age." ); document.login.age.focus(); return false; }

if (document.login.location.selectedIndex == 0 ) { alert ( "Please select your location." ); document.login.location.focus(); return false; } if (!document.login.skills.checked==true) { alert ( "Please select your skills." ); return false; } if (document.login.feedback.value == "" { alert("enter your feedback"); document.login.feedback.focus(); return false; } else { return true; } } //--> </script> </head> document.login.feedback.value==null)

<body bgcolor="#3366FF"> <?php if(isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION[' { echo '<ul class="err">'; foreach($_SESSION['ERRMSG_ARR'] as $msg) { echo '<li>',$msg,'</li>'; } echo '</ul>'; unset($_SESSION['ERRMSG_ARR']); } ?>

<form name="login" id="loginform" method="post" action="register-exec.php" onSubmit="return <table width="500" height="500" border="0" align="center" cellpadding="2" cellspacing="0" <tr>

<th align="left">First Name </th> <td><input name="fname" type="text" class="textfield" id="fname" /></td> </tr> <tr> <th align="left">Last Name </th> <td><input name="lname" type="text" class="textfield" id="lname" /></td> </tr> <tr> <th width="124" align="left">Email</th> <td width="168"><input name="email" type="text" class="textfield" id="login" /></td> </tr> <tr> <th align="left">Password</th> <td><input name="password" type="password" class="textfield" id="password" /></td> </tr> <tr> <th align="left">Confirm Password </th> <td><input name="cpassword" type="password" class="textfield" id="cpassword" /></td> </tr> <tr> <th align="left">Dob</th> <td><input type="dob" name="dob" value="MM-DD-YYYY" ></td> </tr> <tr> <th align="left">Age </th> <td> <select name="age"> <option value="" label="age" selected>age</option> <option value="21" <option value="22" <option value="23" <option value="24" </select> </td> </tr> label="21">21</option> label="22">22</option> label="23">23</option> label="24">24</option>

<tr> <th width="124" align="left">Gender</th> <td> <input type="radio" name="gender" value="Male" >Male <input type="radio" name="gender" value="Female" >Female </td> </tr> <tr> <th align="left">Location</th> <td> <select name="location"> <option value="" label="location" selected>location</option> <option value="india" label="india">india</option> <option value="londan" label="londan">londan</option> <option value="japan" label="japan">japan</option>

<option value="USA" label="USA">USA</option> </select> </td> </tr> <tr> <th align="left">Key skills</th> <td> <input type="checkbox" name="skills" value="c">c <input type="checkbox" name="skills1" value=".Net" >.Net <input type="checkbox" name="skills2" value="Java" >Java<br><br> </td> </tr> <tr> <th align="left">About me </th> <td> <textarea name="feedback" cols=18 rows=3 class="textfield" id="feedback"> </textarea> </td> </tr> </table>

<table> <tr> <td>&nbsp;</td> <td width="1000" height="40" bgcolor="blue" align="center"><input type="submit" name= </tr> </table> </form> <?php include("footer.php"); ?> </body> </html>

Вам также может понравиться