Hi,
I'm adding a form to a page like this:
So I want to include the checkForm function in the page so I have created a UDF called CheckForm and defined it like this:
function checkForm(RememberMeForm)
{
//For First Name
if (!(RememberMeForm.rem_firstname.value))
{
alert("Please enter a First Name")
RememberMeForm.rem_firstname.focus()
return false
}//End Of First Name
//For Surname
if (!(RememberMeForm.rem_surname.value))
{
alert("Please enter a Surname")
RememberMeForm.rem_surname.focus()
return false
}//End Of First Name
}//End Of Function
But when I submit this for saving I get this error message:
Invalid code entered.
Parse error: syntax error, unexpected ')', expecting '&' or T_VARIABLE in /home/www/arrivealivett.com/admin/adduserplugin.php(100) : eval()'d code on line 1
Basically, I want to validate the input on a form and then run a php script to update a database. What am I doing wrong here?
Thanks for any help
How To Add PHP Function as UDT?
Re: How To Add PHP Function as UDT?
The example you gave is JavaScript, not PHP.
Re: How To Add PHP Function as UDT?
Of course! I just assumed it was PHP because it was in a PHP file. So how can I include this javascript code in my CMSMS page?
Re: How To Add PHP Function as UDT?
Put it in your template, usually in the . Wrap {literal} {/literal} around your JavaScript code so that the curly braces doesn't interfere with Smarty processing.
Re: How To Add PHP Function as UDT?
Thanks, I've actually just been putting it in the "Smarty data or logic that is specific to this page:" for the specific page and it appears to work that way. Is this way OK as the code is only specific to this one page?
Re: How To Add PHP Function as UDT?
yes, that is fine (at least it's always worked for me)
You could also put it in your template, but surrounded by a conditional so that it only runs if the template is rendering with a certain page_alias.
You could also put it in your template, but surrounded by a conditional so that it only runs if the template is rendering with a certain page_alias.
Re: How To Add PHP Function as UDT?
How does putting JavaScript in the Smarty Data field work?