Click here to Skip to main content
15,907,913 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
C#
function checkDate(sender,args)
{
//create a new date var and set it to the
//value of the senders selected date
var selectedDate = new Date();
selectedDate = sender._selectedDate;
//create a date var and set it's value to today
var todayDate = new Date();
var mssge = "";

if(  todayDate -selectedDate >=18)
{
/
alert("Warning! - Date of Birth  is  valid  ");
}
}
    Date Of  Birth
            <td style="width: 292px">
            
            <asp:TextBox id="TextBox3" runat="server"  ValidationGroup="a">
 <asp:calendarextender id="CalendarExtender2" targetcontrolid="TextBox3"  runat="server" OnClientDateSelectionChanged="checkDate">>


                <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender3" runat="server" TargetControlID="RequiredFieldValidator3">
                
               
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                    ErrorMessage="RequiredFieldValidator"  Display="None" 
                    ControlToValidate="TextBox3" SetFocusOnError="True" ValidationGroup="a">
              <asp:Button ID="Button1" runat="server" Text="Insert"  ValidationGroup="a" onclick="Button1_Click" 
                    style="width: 48px"  />
                   <asp:Label ID="Label2" runat="server" ForeColor="#FF6600" 
                    Text="Data  Sucessfully Inserted ">
Now   is   coding  inside  button  
 protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            string constr;
            constr = WebConfigurationManager.ConnectionStrings["JAPITConnectionString"].ConnectionString;
            SqlConnection con = new SqlConnection(constr);

            con.Open();
            string str = "insert   into  Doe_detail values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "')";
            SqlCommand cmd = new SqlCommand(str, con);
            cmd.ExecuteNonQuery();
            con.Close();
            Label2.Visible = true;
            TextBox1.Text = "";
            TextBox2.Text = "";
            TextBox3.Text = "";
            TextBox4.Text = "";
            TextBox5.Text = "";
         
        }
        catch (Exception es)
        {
        }
    }</td>
Posted

I think is will help you

http://www.codingforums.com/archive/index.php/t-159040.html[^]




Happy coding :)
 
Share this answer
 
Try Like This In order to differentiate years from dates
JavaScript
var d1=new Date(1984,3,4);
var d2=new Date(2012,3,5);
var msec=d2-d1;
var mpy=1000*60*60*24*365.26;
var noofyears=msec/mpy;
noofyears= Math.floor(noofyears);//it will gives you exact years..

hope helps you..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900