Jump to content

Mascara


luizcvianna

Recommended Posts

Até aonde eu sei, não é possível incluir máscara no DBEDIT. Eu criei uma função que pega o conteúdo digitado e o retorna formatado.

 

Talvez seja possível com a utilização de javascript, mas eu não sei nada a esse respeito.

Link to comment
Share on other sites

Você pode utilizar o Masked Input um Plugin que usa jQuery, veja o exemplo disponibilizado aqui mesmo no fórum:

 

http://forums.unigui.com/index.php?/topic/1741-formatted-input-for-uniedit/?hl=jquery

 

Eu faço assim:

 

Em um Form Base declaro..

 

procedure TFrmCadBase.SetMaskEditUniControl(Ed: TUniControl; MaskStr: String);
begin
  if WebMode then
  begin
    // to version 0.90 UniGui...
    UniSession.AddJS
      (Format('jQuery(function(){jQuery("#%s_id-inputEl").mask("%s");});',
      [Ed.JSName, MaskStr]));
  end;
end;
 
E no Form que vou utilizar faço algo do tipo:
 
procedure TFrmCadPrestador.UniFormShow(Sender: TObject);
begin
  inherited;
  // NelZ
  // Important:
  // Add in UniServerModule, CustomFiles:
  // js/jquery.js
  // js/jquery.maskedinput.js
  // =>Make sure thats files exist in folder.
  //
  // Then use Method SetMaskEditUniControl with mask on event
  // onCreate/onShow, set in event you UniGUI version
  //
  // Examples of Formats:
  //
 
  SetMaskEditUniControl(edtDATA, '99/99/9999');
  SetMaskEditUniControl(edtCEP, '99999-999');
  SetMaskEditUniControl(edtFONE, '(99) 9999-9999');

 SetMaskEditUniControl(edtCPF, '999.999.999-99');

 

end;

 

Observe no comentário como adicionar no ServerModule o Script.

 

Sds

 

Eduardo Belo

 

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...