We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,987 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Through Javascript Textbox to show error Age less than 18

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>
1
Contributor
0
Replies
1
View
vidyade
Newbie Poster
7 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0643 seconds using 2.78MB