Merge pull request #309 from aubrey-b/email-check
Check for a valid email.
This commit is contained in:
commit
974b8877dc
|
@ -42,13 +42,15 @@
|
|||
string _confirm = "";
|
||||
string _email = "";
|
||||
string _displayName = "";
|
||||
bool _isEmailValid = false;
|
||||
|
||||
private async Task Register()
|
||||
{
|
||||
try
|
||||
{
|
||||
_message = "";
|
||||
if (_username != "" && _password != "" && _confirm != "" && _email != "")
|
||||
_isEmailValid = Utilities.IsValidEmail(_email);
|
||||
if (_username != "" && _password != "" && _confirm != "" && _isEmailValid)
|
||||
{
|
||||
if (_password == _confirm)
|
||||
{
|
||||
|
@ -94,4 +96,4 @@
|
|||
{
|
||||
NavigationManager.NavigateTo(NavigateUrl(""));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
using System.Globalization;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Oqtane.Shared
|
||||
{
|
||||
|
@ -217,5 +219,15 @@ namespace Oqtane.Shared
|
|||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsValidEmail(string email)
|
||||
{
|
||||
if (string.IsNullOrEmpty(email)) return false;
|
||||
|
||||
return Regex.IsMatch(email,
|
||||
@"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
|
||||
@"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-0-9a-z]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$",
|
||||
RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user