Tuesday, 7 July 2015

Postal or pincode and Address length validation with javascript

<script type="text/javascript">

   function chkform(form)

   {
   //address validation must be 60 char

if(form.txtadd.value.length < 60 )
        {

 alert("At least  60 word Write ");
 form.txtadd.focus();
 return false;
}

// postal code
re = /^\d{6}$/;

if(!re.test(form.txtcode.value))

      {
 alert("Enter 6 Digit pincode ");
 form.txtcode.focus();
 return  false;
}

 
   }
    </script>
   
     <form name="f2" method="post" enctype="multipart/form-data" style=" margin-top: -100px;"  onsubmit="return chkform(this);">
   
      <textarea name="txtadd"></textarea>
          <input type="text" name="txtcode" placeholder="Enter Postal Code" />
   
    </form>

No comments:

Post a Comment