Question How can i use required field validator with my own javascript

rhedzyie

New member
Joined
Jul 27, 2010
Messages
1
Programming Experience
Beginner
Hi,

I have a form with textbox, a required field validator and a submit button. The scenario should be, when i submit my form i have to confirm if i want to proceed. So, what i did in submit button was this : <asp:Button ID="SubmitButton" OnClientClick="return confirm('Are you sure you want to proceed?')" runat="sever"></asp:Button>. The problem is that the form didn't validate the textbox if it has value in it.

This is the page look like:
HTML:
<form id="Form1" runat="server">
    <asp: TextBox ID="TextBox1" runat="server" />
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"  ControlToValidate="TextBox1" ErrorMessage="This field is required">Required</asp:RequiredFieldValidator>
<asp:Button ID="SubmitButton" OnClientClick="return confirm('Are you sure you want to proceed?')" runat="sever"></asp:Button>
</form>
What should I do?
 
Top Bottom