Tag: getElementById

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: , , , ,
Top