i have 4 textbox ( Name , Password , Repeat Password and Date of birth)
Actually i have 2 methods to validate Name and Password
private static void ValidarNome(string Nome)
{
if (Nome.Trim().Length == 0)
{
string msg = " O nome não pode estar em branco";
ApplicationException e = new ApplicationException(msg);
throw e;
}
}
private static void ValidarSenha(Int32 pw , Int32 pw2 , int check)
{
if (pw != pw2)
{
check = 1;
string msg = " As senhas não conferem";
ApplicationException e = new ApplicationException(msg);
throw e;
}
}
But i need to pick the DateTime in Date of Birth Text and create a new method to validate if this DateTime is between 01/01/1960 - 31/12/1990 , what is the simple way to make this validation ?
EDIT - > With the help of users so was created the method to validate date >
private static void ValidarData(DateTime d,DateTime from,DateTime to, Int32 check2, Int32 check3)
{
if (d < from)
{
check2 = 1;
string msg = " Data de nascimento não aceita";
ApplicationException e = new ApplicationException(msg);
throw e;
}
else if (d > to)
{
check3 = 1;
string msg = " Data de nascimento não aceita";
ApplicationException e = new ApplicationException(msg);
throw e;
}
else
{
string msg = " Cadastro Incluído";
}
}