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>

About

me : yeay its me arun

Tagged with: , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.