Reputation: 85
I am using a RequiredFieldValidator and the error message that I created shows up but the information still saves. How do I fix this ?
here is the code
<th align="left">RFP EXP:</th>
<td>
<GMDP:GMDatePicker ID="rfpExpDatePicker" runat="server" OnPreRender = "rfpExpDatePicker_DateChanged" CalendarFont-Names="Arial" InitialText="Select a Date" InitialValueMode="Null">
<CalendarDayStyle Font-Size="9pt" />
<CalendarTodayDayStyle BorderWidth="1px" BorderColor="DarkRed" Font-Bold="True" />
<CalendarOtherMonthDayStyle BackColor="WhiteSmoke" />
<CalendarTitleStyle BackColor="#E0E0E0" Font-Names="Arial" Font-Size="9pt" />
<CalendarFont Names="Arial" />
</GMDP:GMDatePicker>
<asp:RequiredFieldValidator
ControlToValidate="rfpExpDatePicker" Text="You Must Choose a date before the info will save" runat="server" />
Upvotes: 0
Views: 223
Reputation: 47736
Have you wrapped your button's Click event a valid check?
if (Page.IsValid)
{
// do something...
}
You can't rely on the client side javascript to do the error trapping for you so always implement the server side check.
Upvotes: 2