I have two inputs at my FORM:
$_siape and
$_data_nasc
before sending the form, I would like it to run a function that checks if the value of these two fields are correct.
see a little of my script for run before sending form:
require_once('lib/nusoap.php');
function validarProfessor($_siape=NULL,$_data_nasc=NULL,&$_resposta){
$_retorna = FALSE;
if (!is_null($_siape) AND !is_null($_data_nasc)){
if (($_data_nasc{2}=="/")AND($_data_nasc{5}=="/")AND(strlen($_data_nasc)==10)){
list($_dia, $_mes, $_ano) = explode('/', $_data_nasc);
if (!checkdate(intval($_mes),intval($_dia),intval($_ano))) {
$_resposta = "Data inválida!";
return $_retorna;
}
$_data_nasc = $_ano."-".$_mes."-".$_dia;
}elseif (($_data_nasc{4}=="-")AND($_data_nasc{7}=="-")AND(strlen($_data_nasc)==10)){
list($_ano, $_mes, $_dia) = explode('-', $_data_nasc);
if (!checkdate(intval($_mes),intval($_dia),intval($_ano))) {
$_resposta = "Data inválida!";
return $_retorna;
}
$_data_nasc = $_ano."-".$_mes."-".$_dia;
}else{
$_resposta = "Formato inválido de data (esperado dd/mm/aaaa)!";
return $_retorna;
}
}else{
$_resposta = "Faltando parâmetros obrigatórios!";
return $_retorna;
}
$cliente = new SoapClient("http://XXXXX?wsdl",true);
//$cliente->setCredentials("XXX","XXX",'XXX');
$cliente->setCredentials("XXX","XXX",'XXX');
$erro = $cliente->getError();
if ($erro) {
$_resposta = $erro;
}
$result = $cliente->call('isProfessorAtivoBySiape', array($_siape,$_data_nasc));
if ($cliente->fault){
$_resposta = $result;
}else{
$erro = $cliente->getError();
if ($erro){
$_resposta = $erro;
}else{
$_retorna = (strtoupper($result)=='TRUE')?TRUE:FALSE;
}
}
return $_retorna;
}
?>
$_siape and
$_data_nasc
before sending the form, I would like it to run a function that checks if the value of these two fields are correct.
see a little of my script for run before sending form:
require_once('lib/nusoap.php');
function validarProfessor($_siape=NULL,$_data_nasc=NULL,&$_resposta){
$_retorna = FALSE;
if (!is_null($_siape) AND !is_null($_data_nasc)){
if (($_data_nasc{2}=="/")AND($_data_nasc{5}=="/")AND(strlen($_data_nasc)==10)){
list($_dia, $_mes, $_ano) = explode('/', $_data_nasc);
if (!checkdate(intval($_mes),intval($_dia),intval($_ano))) {
$_resposta = "Data inválida!";
return $_retorna;
}
$_data_nasc = $_ano."-".$_mes."-".$_dia;
}elseif (($_data_nasc{4}=="-")AND($_data_nasc{7}=="-")AND(strlen($_data_nasc)==10)){
list($_ano, $_mes, $_dia) = explode('-', $_data_nasc);
if (!checkdate(intval($_mes),intval($_dia),intval($_ano))) {
$_resposta = "Data inválida!";
return $_retorna;
}
$_data_nasc = $_ano."-".$_mes."-".$_dia;
}else{
$_resposta = "Formato inválido de data (esperado dd/mm/aaaa)!";
return $_retorna;
}
}else{
$_resposta = "Faltando parâmetros obrigatórios!";
return $_retorna;
}
$cliente = new SoapClient("http://XXXXX?wsdl",true);
//$cliente->setCredentials("XXX","XXX",'XXX');
$cliente->setCredentials("XXX","XXX",'XXX');
$erro = $cliente->getError();
if ($erro) {
$_resposta = $erro;
}
$result = $cliente->call('isProfessorAtivoBySiape', array($_siape,$_data_nasc));
if ($cliente->fault){
$_resposta = $result;
}else{
$erro = $cliente->getError();
if ($erro){
$_resposta = $erro;
}else{
$_retorna = (strtoupper($result)=='TRUE')?TRUE:FALSE;
}
}
return $_retorna;
}
?>
Hi osnysantos,
You can't run PHP on the client side (i.e. in the form). You can either set this up as server side validation; or re-write it in JavaScript to run from the client side.
The 'required' and 'date' validations can probably be done with the exisiting ChronoForms validation - with maybe a new validator.
The Soap validation would presumably need to be written in AJAX???
Bob
You can't run PHP on the client side (i.e. in the form). You can either set this up as server side validation; or re-write it in JavaScript to run from the client side.
The 'required' and 'date' validations can probably be done with the exisiting ChronoForms validation - with maybe a new validator.
The Soap validation would presumably need to be written in AJAX???
Bob
there is not enough to do with js. because he seeks in a database ... to whether or not there is the teacher.
this is possible?
this is possible?
This topic is locked and no more replies can be posted.