Validate Data

P

Peter

I need to validate 4 fields on ASP.NET web page

Starting Date __/__/____ Starting Time __:__
Ending Date __/__/____ Ending Time __:__

Staring Date + StartingTime can not be later then Ending Date + Ending Time
(the starting and ending Times are dropdown boxes)

How would I validate these two values with Validator Controls?


Thanks

Peter
 
J

Jon Paal

google this

datetime.compare


I need to validate 4 fields on ASP.NET web page

Starting Date __/__/____ Starting Time __:__
Ending Date __/__/____ Ending Time __:__

Staring Date + StartingTime can not be later then Ending Date + Ending Time
(the starting and ending Times are dropdown boxes)

How would I validate these two values with Validator Controls?


Thanks

Peter
 
T

Tom.PesterDELETETHISSS

The code below checks dates in 2 textboxes. If you want to campare input
that is scatered over gui elements try to concatenate them and copy them
in hidden fields and compare with them.
I haven't done this and leave it as an exercice :)

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Val.aspx.cs" Inherits="Val"
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="TextBox1"
ControlToValidate="TextBox2" ErrorMessage="Date 2 must be after
Date 1" Operator="GreaterThan"
Type="Date"></asp:CompareValidator>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" /></div>
</form>
</body>
</html>


Let me know if you have any more questions...

Cheers,
Tom Pester
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top