bueno lo que pasa es que quiero utilizar el validatoremail y el del telefono pero no se como
mi componente se llama altaInstructor en el e puesto los label, las cajas de texto y el boton salir y aceptar.
Código Flex :
<?xml version="1.0" encoding="utf-8"?> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="234"> <mx:Script source="Ascript/altaInstructor.as"/> <mx:Label x="57" y="12" text="Nombre :" id="label2" fontWeight="bold"/> <mx:Label x="52" y="158" text="Empresa:" fontWeight="bold"/> <mx:Label x="52" y="98" text="Telefono :" fontWeight="bold"/> <mx:Label x="70" y="128" text="Email :" fontWeight="bold"/> <mx:TextInput restrict="0-9" x="121" y="96" id="txttelefono" maxChars="10"/> <mx:TextInput restrict="a-z @.W" x="121" y="126" id="txtemail"/> <mx:TextInput restrict="a-z " x="119" y="10" width="263" id="txtnombre"/> <mx:LinkButton x="314" y="200" label="Cancelar" click="cancelarSalir()"/> <mx:LinkButton x="240" y="200" label="Aceptar" click="checavacios()"/> <mx:TextInput restrict="a-z 0-9" x="121" y="156" width="237" id="txtempresa"/> <mx:Label x="10" y="68" text="Apellido Materno:" fontWeight="bold"/> <mx:Label x="10" y="38" text="Apellido Paterno:" fontWeight="bold"/> <mx:TextInput restrict="a-z " x="119" y="36" width="263" id="txtpaterno"/> <mx:TextInput restrict="a-z " x="119" y="66" width="263" id="txtmaterno"/> </mx:Canvas>
luego tengo el actionScript siguiente
Código ActionScript :
// ActionScript file
import mx.controls.*;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
var funcionCancel:Function;
var https:HTTPService = new HTTPService;
var https2:HTTPService = new HTTPService;
var https3:HTTPService = new HTTPService;
//boton Cancelar
public function addeventoCancelarIn(cancel:Function):void
{
funcionCancel=cancel;
}
private function cancelarSalir():void
{
funcionCancel.call();
limpiaalta();
}
//alta de instructor
private function checavacios():void
{
if(txtnombre.text=="" || txtpaterno.text==""||txtmaterno.text==""||txtempresa.text=="" || txttelefono.text=="" || txtemail.text=="")
{
Alert.show('Existe(n) campo(s) en blanco');
}
else //aqui esdonde creo debe de ir otro if para ver si esta bien el correo y el telefono
{
checa();
}
}
//checa alta
private function checa():void
{
var param:Object = new Object();
param["nombre"]=txtnombre.text;
param["paterno"]=txtpaterno.text;
param["materno"]=txtmaterno.text;
https.resultFormat = "e4x";
https.url = "http://localhost/sacado/checaaltai.php";
https.method = "POST";
https.addEventListener(ResultEvent.RESULT,resul);
https.send(param);
}
private function resul(evento:ResultEvent):void
{
https.removeEventListener(ResultEvent.RESULT,resul);
if (evento.result.toString()=='no')
{
altaInstru();
}
else if(evento.result.toString()!= 'no')
{
Alert.show("El Instructor ya existe");
return;
}
}
//alta
private function altaInstru():void
{
var param2:Object = new Object();
param2["ram"]=iRandom;
param2["nombre"]=txtnombre.text;
param2["paterno"]=txtpaterno.text;
param2["materno"]=txtmaterno.text;
param2["telefono"]=txttelefono.text;
param2["email"]=txtemail.text;
param2["empresa"]=txtempresa.text;
https2.resultFormat = "e4x";
https2.url = "http://localhost/sacado/altai.php";
https2.method = "POST";
https2.send(param2);
limpiaalta();
}
//limpia alta de instructor
private function limpiaalta():void
{
txtnombre.text="";
txtpaterno.text="";
txtmaterno.text="";
txttelefono.text="";
txtemail.text="";
txtempresa.text="";
}Lo que quiero hacer es que al presionar el boton aceptar se mande llamar a checavacios() y que ya que verifique que no hay vacios tambiem verifique que este bien escrito el correo y el telefono (con validator...) si esta bien manda llamar a checa() y si no mande un mensaje para que el usuario corrija.
De antemano mil gracias a quien me pueda ayudar.
