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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...