Welcome Guest, Not a member yet? Register   Sign In
validation form
#1

[eluser]abada[/eluser]
hi all :-)

iam trying to use javascript validation in form

i found it in User Guide
Quote:
Code:
$js = 'onClick="some_function()"';

echo form_button('mybutton', 'Click Me', $js);

and when use javascript function appear this error

Quote:Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in D:\wamp\www\nps\system\application\views\users_register.php on line 66

and this my code
Code:
<? $js ='onClick="compare(regforum.name,'','please enter your name',1,'nameDiv')"';

echo form_button('save', 'Register', $js); ?>

compare fn check if user name is empty or not

thanks 4 ur help

abada
#2

[eluser]moodh[/eluser]
Code:
<? $js ="onClick=\"compare(regforum.name,'','please enter your name',1,'nameDiv')\"";

You need to escape chars that's the same as the one you enclose the string with, for example $var = ' ' need to escape all ' inside, and $var = " " need to escape \" inside. =)
#3

[eluser]abada[/eluser]
thnx very much narcisha

it success




Theme © iAndrew 2016 - Forum software by © MyBB