View Single Post
  #1 (permalink)  
Old 23rd March 2009, 06:28
fleong888 fleong888 is offline
D4PHP Newbie
 
Join Date: Mar 2009
Posts: 7
fleong888 is on a distinguished road
Default How to create and run a function in a php form?

//Class definition
class Form_IDRetriever extends Page
{
public $vLinkBtn = null;
public $vSendBtn = null;
public $vEMail = null;
public $vPasswordPanel = null;
public $Label1 = null;
public $Label2 = null;
function Form_IDRetrieverJSLoad($sender, $params)
{
?>
//Add your javascript code here
{document.getElementById('vEMail').focus();}
<?php
}

function Form_IDRetrieverJSSubmit($sender, $params)
{
?>
//Add your javascript code here

function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2)
{alert(alerttxt);return false;}
else {return true;}
}
}
//-------------------------------------
{
if (findObj('vEMail').value=='')
{alert("Please enter a Email Address");
document.getElementById('vEMail').focus();
return(false);}
else
if (validate_email($this->vEMail,"Not a valid e-mail address!")==false)
{$this->vEmail.focus(); return(false);}
}
<?php

}

}

Is this the correct way to create a function call validate_email?
Thank you
Reply With Quote
Sponsored Links