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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...