vidyade 0 Newbie Poster
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>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.