Ciao ragazzi,
sto cercando di creare una pagina web in cui un utente si deve registrare, quando però verifico che i dati siano scritti in forma corretta viene generato l'errore "dati scritti in forma non corretta".
Sono per caso sbagliate le espressioni regolari? O mi sorge un dubbio, txtPhoneNumber.Text è per caso sbagliato visto che verranno inseriti numeri?
Scusate non sono molto esperta, ho iniziato ad usare VS ieri pome...
codice:private bool ValidateEmail() { string email = txtEmail.Text; Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); Match match = regex.Match(email); if (match.Success) return true; else return false; } private bool ValidatePhoneNumber() { string phone = txtPhoneNumber.Text; Regex regex = new Regex(@"^(\+39)[0-9]{10}$"); Match match = regex.Match(phone); if (match.Success) return true; else return false; }

Rispondi quotando