Below are the script by which you can validate email id and mobile number field.
Step 1: Make the form
<div class="form-level"> <input type="text" class="form-control" name="email" placeholder="Email Id" /> <span class="form-icon fa fa-envelope"></span> </div> <div class="form-level"> <input name="mobile" placeholder="Enter your Mobile Number" id="mobile" class="form-control" value="" type="text"> <span class="form-icon fa fa-phone"></span> </div> Now apply the below script in your head section var email = document.fromValidate.email; var mobile = document.fromValidate.email; if(email.value==''){ window.alert('Pleaseer the email id'); email.focus(); return false; } if(email.value.indexOf('@',0 window.alert('Pleaseer the valid email'); email.focus(); return false; } if(email.value.indexOf('.',0 window.alert('Pleaseer the valid email'); email.focus(); return false; } if(mobile.value==''){ window.alert('Pleaseer the mobile number') mobile.focus(); return false; } if(mobile.value.length<10 window.alert('Pleaseer valid mobile number'); mobile.focus(); } if(mobile.value.length>10 window.alert('Pleaseer valid mobile number'); mobile.focus(); } if(!parseInt(mobile.value)){ window.alert("Enterts only"); mobile.focus(); return false; } return true; }
No comments:
Post a Comment