-
Notifications
You must be signed in to change notification settings - Fork 0
/
Validacion.cs
36 lines (33 loc) · 1.24 KB
/
Validacion.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
namespace Util
{
public class Validacion
{
public static bool ValidarEmail(string email)
{
String expresion;
expresion = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
if (Regex.IsMatch(email, expresion))
{
if (Regex.Replace(email, expresion, String.Empty).Length == 0)
return true;
else
return false;
}
return false;
}
public static bool ValidarNum(string num)
{
return !Regex.IsMatch(num, @"^\d+$");
}
public static bool ValidarFecha(string fecha)
{
return !Regex.IsMatch(fecha, @"^(((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00|[048])))$");
}
}
}