Robert1995 Posted September 11, 2011 Report Posted September 11, 2011 Poate este cineva pe aici care are nevoie de asa ceva . Sunt doar 3 fielduri pentru ca nu aveam chef de copy paste sa fac un formular complet<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script><script>$(document).ready(function(){ $('.input_prepop').focus(function(){ if($(this).val()==$(this).attr('alt')) $(this).val(''); }); $('.input_prepop').blur(function(){ if($(this).val()=='') $(this).val($(this).attr('alt')); }); $('#false_check').live('click',function(event){ event.preventDefault(); inputs = $(".input_prepop"); var items = inputs.length; var not_good = 'Please complete the following <<:>>'; var prevent = false; for(i=0; i<items ; i++){ if(inputs[i]['value'] == inputs[i]['alt']){ not_good = not_good + ',' + inputs[i]['alt']; prevent = true; } } not_good = not_good.replace('<<:>>,' , ': '); if(prevent == true){ alert(not_good); }else{ $('#real_submit').click(); } });});</script><style>.clear{ clear: both; border: 0px;}.button{ color:white; background-color:blue; padding:10px; text-decoration:none; font-weight:bold; border: 1px solid #999999; min-width:100px;}form .error{ display:block; clear:both; font-size: 15px;color:red; }form .field{ display: block; clear: both; margin-bottom: 10px; }form .field label{ display: inline-block; width: 100px; float: left; margin: 2px 5px 0px 0px; font-size: 15px; }form .field input[type=text],form .field input[type=password]{ display: inline-block; float: left; width: 300px; padding:4px; }</style><?php if(isset($_POST['submit'])){ $data = isset($_POST['user']) ? $_POST['user'] : array(); // Check for errors if(!empty($data)){ /** Sanitize */ foreach($data as $k=>$d){ $data[$k] = htmlentities($d); } if(trim($data['email']) == '' || $data['email'] == 'Email'){ $errors['email'] = 'This Field is required'; }else{ if(strpos($data['email'] , '@') == false){ $errors['email'] = 'Please enter a valid email'; } } if(trim($data['first_name']) == '' || $data['first_name'] == 'First Name'){ $errors['first_name'] = 'This Field is required'; }else{ if(!ctype_alpha($data['first_name'])){ $errors['first_name'] = 'Only alphanumeric caracter allowed'; } } if(trim($data['last_name']) == '' || $data['last_name'] == 'Last Name'){ $errors['last_name'] = 'This Field is required'; }else{ if(!ctype_alpha($data['last_name'])){ $errors['last_name'] = 'Only alphanumeric caracter allowed'; } } if(empty($errors)){ /** Salveaza in sql , etc etc etc*/ } } }?><html><head></head><body><form method="post" action=""> <div class="field"> <label>Email</label> <input type="text" class="input_prepop" name="user[email]" alt="Email" value="<?php echo isset($data['email']) ? $data['email'] : 'Email';?>"/> <div class="error"><?php echo isset($errors['email']) ? $errors['email'] : '';?></div> </div> <div class="field"> <label>First Name</label> <input type="text" class="input_prepop" name="user[first_name]" alt="First Name" value="<?php echo isset($data['first_name']) ? $data['first_name'] : 'First Name';?>"/> <div class="error"><?php echo isset($errors['first_name']) ? $errors['first_name'] : '';?></div> </div> <div class="field"> <label>Last Name</label> <input type="text" class="input_prepop" name="user[last_name]" alt="Last Name" value="<?php echo isset($data['last_name']) ? $data['last_name'] : 'Last Name';?>"/> <div class="error"><?php echo isset($errors['last_name']) ? $errors['last_name'] : '';?></div> </div> <div style="display : none"> <input id="real_submit" type="submit" name="submit" value="Register" /> </div> <a id="false_check" class="button">Register</a></form></body></html> Quote