AJAX:- TO CHECK IF EMAIL ALREADY EXISTS....
<td align="left" valign="top">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtEmail" AutoPostBack="true" CssClass="textbox_reg"
OnTextChanged="txtEmail_TextChanged" MaxLength="50" runat="server"></asp:TextBox>
<div id="UserAvailability" runat="server" class="messages"></div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:RequiredFieldValidator ID="rfv_email" ValidationGroup="submit" runat="server"
ErrorMessage="Please enter the Email."
ControlToValidate="txtEmail" Display="Dynamic"
Font-Size="X-Small" SetFocusOnError="True">*</asp:RequiredFieldValidator>
<cc1:ValidatorCalloutExtender TargetControlID="rfv_email" ID="VCE_email" runat="server">
</cc1:ValidatorCalloutExtender>
<asp:RegularExpressionValidator ID="rev_email" ValidationGroup="submit" runat="server"
ErrorMessage="Email not in proper format.Please enter again." ControlToValidate="txtEmail"
Display="Dynamic" Font-Size="X-Small" SetFocusOnError="True" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
<cc1:ValidatorCalloutExtender TargetControlID="rev_email" ID="VCE_emailFormat" runat="server"></cc1:ValidatorCalloutExtender>
</td>
protected void txtEmail_TextChanged(object sender, EventArgs e)
{
DataTable dt = new DataTable();
string sql = "select Email From tbl_user Where Email='" + txtEmail.Text.Trim() + "'";
dt = NSBuilder.DataAccess.GetDataSetwitrhcommand(sql).Tables[0];
if (dt.Rows.Count > 0)
{
UserAvailability.InnerText = "Email already taken,Please change!!";
}
else
{
UserAvailability.InnerText = "";
}
}
0 comments:
Post a Comment