Blog Archives

How to validate Phone number Field using Javascript

//phone number validation start var digits = “0123456789″; var phoneNumberDelimiters = “()- “; var validWorldPhoneChars = phoneNumberDelimiters + “+”; var minDigitsInIPhoneNumber = 10; function isInteger(s) {   var i; for (i = 0; i < s.length; i++) { // Check that

Tagged with: , , ,
Posted in javascript, Programming

How to validate image File field using Javascript

<script type=”text/javascript”> function validateFileExtension(ld) { if(!/(\.bmp|\.gif|\.jpg|\.jpeg)$/i.test(ld.value)) { alert(“Invalid image file type.”); ld.form.reset(); ld.focus(); return false; } return true; } </script>

Tagged with: , , ,
Posted in javascript, Programming

How to validate Email Address Using Javascript

<script language=”javascript” type=”text/javascript”> function checkemail(id) { var email = document.getElementById(id); var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (!filter.test(email.value)) { alert(‘Please provide a valid email address’); email.focus; return false; } return true; } </script>

Tagged with: , , , ,
Posted in javascript, Programming

How to validate name field using Javascript

<script language=”javascript” type=”text/javascript”> function isValidName(id) {   Element=document.getElementById(id); if (Element.value==””||Element.value== 0) { alert(“Please Enter your Name.”); Element.focus(); Element.value=””; return false; } var rg = new RegExp(/^[A-Za-z\s'.]+$/gi); name=Element.value; if(String(rg.test(name))==’false’) { Element.focus(); Element.value=””; alert(“Please Enter A valid Name”); return false; } } </script>

Tagged with: , , , ,
Posted in javascript, Programming