Facebook is a showcase of great UI design. And as it has become a major part of our lives, it has also raised the bar for web development, pushing developers to meet higher expectations.
Registration form with mendatory input fileds
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | <html><!--<![endif]--><head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Starkbook Demo | Facebook like registration form using jQuery</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" type="text/css" href="css/stark.css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="js/script.js"></script> <link rel="stylesheet" href="css/normalize.css"> <link rel="stylesheet" href="css/style.css"> <link rel="stylesheet" href="css/main.css"> <style> .maincontnr { background: none repeat scroll 0 0 #F9F9F9; border: 1px solid #CCCCCC; margin: 8px auto 0; min-height: 650px; width: 980px; } .header-container, .footer-container, .main aside { background: none !important; margin-top: 30px; } h2 { margin:40px 0px 40px 20px; } .cssselector { border: 1px solid #CCCCCC; box-shadow: 0 0 6px #D1CFD5 inset; float: left; margin-left: 86px; margin-top: 20px; min-height: 295px; padding: 30px; width: 300px; } .footer-container, .main aside { border-top: 20px solid #3B5998; clear: both; } .header-container, .footer-container, .main aside { background: none repeat scroll 0 0 #A7A7A7; margin-top: 0px !important; } .cssselector h3 { font-size: 20px; font-weight: bold; margin: 0px; } .cssselector ul { margin: 0 0 15px 25px; } li:nth-of-type(3) { color: #DD0404; margin-left: 25px; } div.fifth p:nth-child(5) { color: #DD0404; margin-left: 25px; } </style> </head> <body> <!--[if lt IE 7]> <p class="chromeframe">You are using an outdated browser. <a href="http://browsehappy.com/">Upgrade your browser today</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to better experience this site.</p> <![endif]--> <div id="sbBarHolder" class="slim"> <div class=" fixed_elem" id="sbBar"> <div class="clearfix"> <a href="http://www.starkbook.com/"> <img alt="" src="http://www.starkbook.com/wp-content/themes/ifeature/images/555.png" height="35" width="140"> </a> <div class="sbsearch"> <li id="search-7" class="widget widget_search"><form role="search" method="get" id="searchform" action="http://www.starkbook.com/"> <div class="sbsearchbox"> <input name="s" id="s" style="padding: 1px 1px 1px 5px; color: #828282;width: 300px;border:none;border-right:1px solid #ccc;" type="text"><input id="searchsubmit" value="" style="background:#fff; border-radius: 0 0 0 0;width:20px;background-image: url(https://s-static.ak.fbcdn.net/rsrc.php/v1/yV/r/wPWUfETd_cS.png) !important; background-position: -2px -44px; border:none;margin-top:2px;" type="submit"/> <!--<input type="submit" id="searchsubmit" value="Search" />--> </div> </form></li> </div> </div> </div> </div> <div class="main-container"> <div class="maincontnr"> <h2>Facebook like registration form using jQuery</h2> <div id="div-regForm"> <div class="form-title">Sign Up</div> <div class="form-sub-title">It's free and always will be</div> <form id="regForm" action="submit.php" method="post"> <table> <tbody> <tr> <td><label for="fname">First Name:</label></td> <td><div class="input-container"><input name="fname" id="fname" type="text" /></div></td> </tr> <tr> <td><label for="lname">Last Name:</label></td> <td><div class="input-container"><input name="lname" id="lname" type="text" /></div></td> </tr> <tr> <td><label for="email">Your Email:</label></td> <td><div class="input-container"><input name="email" id="email" type="text" /></div></td> </tr> <tr> <td><label for="pass">New Password:</label></td> <td><div class="input-container"><input name="pass" id="pass" type="password" /></div></td> </tr> <tr> <td><label for="sex-select">I am:</label></td> <td> <div class="input-container"> <select name="sex-select" id="sex-select"> <option value="0">Select Sex:</option> <option value="1">Female</option> <option value="2">Male</option> </select> </div> </td> </tr> <tr> <td><label>Birthday:</label></td> <td> <div class="input-container"> <select name="month"><option value="0">Month:</option><?=generate_options(1,12,'callback_month')?></select> <select name="day"><option value="0">Day:</option><?=generate_options(1,31)?></select> <select name="year"><option value="0">Year:</option><?=generate_options(date('Y'),1900)?></select> </div> </td> </tr> <tr> <td> </td> <td><input type="submit" class="greenButton" value="Sign Up" /><img id="loading" src="img/ajax-loader.gif" alt="working.." /> </td> </tr> </tbody> </table> </form> <div id="error"> </div> <div id="clouds"></div> </div> </div> </div> </body></html> |
Validation code to check input fields.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | <?php // we check if everything is filled in if(empty($_POST['fname']) || empty($_POST['lname']) || empty($_POST['email']) || empty($_POST['pass'])) { die(msg(0,"All the fields are required")); } // is the sex selected? if(!(int)$_POST['sex-select']) { die(msg(0,"You have to select your sex")); } // is the birthday selected? if(!(int)$_POST['day'] || !(int)$_POST['month'] || !(int)$_POST['year']) { die(msg(0,"You have to fill in your birthday")); } // is the email valid? if(!(preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $_POST['email']))) die(msg(0,"You haven't provided a valid email")); // where member-area.php is the address on your site where registered users are // redirected after registration. echo msg(1,"home.html"); function msg($status,$txt) { return '{"status":'.$status.',"txt":"'.$txt.'"}'; } ?> |
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: Facebook, Javasrcipt, Jquery, PHP