30 Aug 2013

How to Pan Card Validation in Asp.net.

Hello,

Below script helps to bind the user to enter the value in the textbox which
will validate pan card number in India.

In India Pan card no is 10 digit alpha numeric.
First 5 are alphabets only followed by 4 numeric and at last one alphabet.


To achieve this simply follow the following Steps

Write the below javascript function in the aspx page under head section :


<script type="text/javascript">
function Validation()
{
var txt_pan=document.getElementById('TextBox1').value;

var checkval=/^[A-Z]{5}\d{4}[A-Z]{1}$/;
if(checkval.test(txt_pan)== false)
{
  alert('Please enter valid pan number');
  return false;
}
}
</script>

In the Body Section of the .aspx page just bind the onClientclickevent of the button to the function above in the javascript to check the value of TextBox1
Take one texbox and button control on the page as shown below


<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="javascript:return Validation();" />

How to Create WEBSITE DESIGN

Way2finder Technologies is a web design studio that offers corporate web design and custom web design. Our website designers offer cheap w...