I need to check if a user is already exsit before the user is submitting the form. here is my signup.aspx form:
<form name="sign_up" method="post" id="sign_up" runat="server">
<div style="margin:auto;width:40%;border:solid;background-color:white">
<div style="padding-bottom:6px;background-color:gray;width:100%;">
<h2 style="color:black;text-align:center">Sign-Up</h2>
<p style="color:black;text-align:center">Already Have An Accout? <a href="login.aspx">Login</a></p>
</div>
<br />
<table>
<tr>
<td><asp:TextBox ID="name" cssclass="textboxfocus" placeholder="Name" name="name" required="required" runat="server"></asp:TextBox> </td>
<td><asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="name" Display="Dynamic" ErrorMessage="Name Must be At least 3 chars" ForeColor="red" ValidationExpression="^[sS]{3,1000}$"></asp:RegularExpressionValidator></td>
<td><asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Name already exsist" Display="Dynamic" ControlToValidate="name" ForeColor="Red" onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator></td>
</tr>
<tr>
<td> <asp:TextBox ID="email" TextMode="Email" placeholder="Email" name="email" required="required" runat="server"></asp:TextBox></td>
<td><asp:regularexpressionvalidator runat="server" errormessage="Please enter a valid email" Display="Dynamic" ControlToValidate="email" ForeColor="Red" ValidationExpression="w+([-+.']w+)*@w+([-.]w+)*.w+([-.]w+)*"></asp:regularexpressionvalidator></td>
</tr>
<tr>
<td><asp:TextBox ID="password" TextMode="Password" placeholder="Password" name="password" required="required" runat="server"></asp:TextBox></td>
<td>
<asp:regularexpressionvalidator ValidationExpression = "^(?=.*[A-Za-z])(?=.*d)[A-Za-zd]{8,}$" runat="server" ForeColor="red" ControlToValidate="password" errormessage="Minimum 8 characters required, at least 1 Alphabet and 1 Number"></asp:regularexpressionvalidator></td>
</tr>
<tr>
<td><asp:TextBox ID="repassword" TextMode="Password" placeholder="Repeat Password" name="repassword" required="required" runat="server"></asp:TextBox></td>
<td> <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="password" ControlToValidate="repassword" ErrorMessage="Passwords Dont matched" ForeColor="Red" Display="Dynamic"></asp:CompareValidator></td>
</tr>
</table>
<br />
<asp:Button ID="submit" runat="server" Text="Submit" OnClick="submit_Click" />
<input type="reset" value="Reset" />
</div>
I placed a custom validator but i dont know how to use it can anyone write me the c# function for it? thx!
Aucun commentaire:
Enregistrer un commentaire