<html> <head> <title>Sample Code</title> <script type="text/javascript"> function CheckIndianZipCode(MyZipCode) { var CheckZipCode = /(^\d{6}$)/; if(CheckZipCode.test(MyZipCode)) { document.getElementById('p1').innerHTML ="valid"; } else { document.getElementById('p1').innerHTML ="Your Entered Zip Code Is Not Valid."; } } </script> </head> Enter String : <input type="text" name="txtOriginal" onKeyup="CheckIndianZipCode(this.value);" /><br> <p id="p1">Hello Ankur</p>