Helpful Information
 
 
Category: JavaScript Development
PHP + JavaScript

I only want to do a function with an alert messagge in the following way:
I mean I want to validate a Username field, so I get the value from a DB with PHP and then I want to pass that value to a JS function,

eg.

$name= from a DB;
the form which I have to validate:
<form name=form method="post" onsubmit="return validate()">
....
....
how can I pass $name like a parameter in the validate() function? because "return validate(name)" doesn't work.

thanks in advance.

<form name=form method="post" onsubmit="return validate(<? print $name ?>)">

?

<form name=form method="post" onsubmit="return validate(this)">

you just have to use "this" in the ()'s

Try "return validate('<?php echo $name; ?>')"

Originally posted by Ulrik N
<form name=form method="post" onsubmit="return validate(this)">

you just have to use "this" in the ()'s

he already said he tried this and it didnt work and wanted a way to put the variable in.

and did my post turn invisible?

To pass to your function the value of "name" textfield use the following: return validate(this.name.value)










privacy (GDPR)