Jump to content

Email Client Side Validation Translation


M.Ammar

Recommended Posts

Hi All

I used the code below For an Email Client Side Validation       

UniEdit1 -> ClientEvents -> UniEvents   add the following beforeinit code:

function beforeInit(sender, config)
{
  Ext.apply(sender,{allowBlank:false,vtype:'email',msgTarget : 'side'});
}

it is working fine, but I have 2 questions

- 1-How to translate the message coming as hint " This Field Should be an-email Address Format … "

-2 - How To use this Client Side Validation In Delphi code to know before saving the query if it is valid or not.

Best Regards

 

Link to comment
Share on other sites

function IsValidEmail(const Value: string): Boolean;
function CheckAllowed(const s: string): Boolean;
  var i: Integer;
  begin
    Result:= false;
    for i:= 1 to Length(s) do
      if not (s[i] in ['a'..'z',
                       'A'..'Z',
                       '0'..'9',
                       '_',
                       '-',
                       '.']) then Exit;
    Result:= true;
  end;
var
  i: Integer;
  NamePart, ServerPart: string;
begin
  Result:= False;
  i:=Pos('@', Value);
  if i=0 then Exit;
  NamePart:=Copy(Value, 1, i-1);
  ServerPart:=Copy(Value, i+1, Length(Value));
  if (Length(NamePart)=0) or ((Length(ServerPart)<5)) then Exit;
  i:=Pos('.', ServerPart);
  if (i=0) or (i>(Length(serverPart)-2)) then Exit;
  Result:= CheckAllowed(NamePart) and CheckAllowed(ServerPart);
end;

 

  • Like 1
  • Upvote 1
Link to comment
Share on other sites

most commonly method is:

function IsValidEmail(const Value: string): boolean;
var
 i: integer;
 NamePart, ServerPart: string;
begin
 Result := False;
 i := Pos('@', Value);
 if i = 0 then
  Exit;
 NamePart := Copy(Value, 1, i - 1);
 ServerPart := Copy(Value, i + 1, Length(Value));
 if (Length(NamePart) = 0) or ((Length(ServerPart) < 5)) then
  Exit;
 i := Pos('.', ServerPart);
 if (i = 0) or (i > (Length(ServerPart) - 2)) then
  Exit;
 Result := True;
end;

email can contain not only latin characters

  • Like 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...