Advertisement
a1t0rmenta

Validar campo email power apps

Aug 25th, 2023
864
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function validaremail(executionContext) {
  2.     var formContext = executionContext.getFormContext();
  3.     var campoAValidar = formContext.getAttribute("emailaddress1").getValue();
  4.  
  5.     // ======================== VALIDAR EMAIL
  6.  
  7.     // Campo vacío, contener @,
  8.     if (campoAValidar === null) {
  9.         return "El correo no puede estar vacío.";
  10.     }
  11.  
  12.     // Contener @ (mejorar a que sea solo una)
  13.     if (campoAValidar.search("@") === -1) {
  14.         formContext.getControl("emailaddress1").setNotification("El email debe contener una @");
  15.     } else {
  16.         formContext.getControl("emailaddress1").clearNotification();
  17.     }
  18.  
  19.     // método test para recorrer string
  20.     if (/^[@#$%^&*!]/.test(campoAValidar)) {
  21.         formContext.getControl("emailaddress1").setNotification("El email no debe empezar con @ o símbolos raros");
  22.         return;
  23.     }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement