Hi. I just wonder, is it possible, to validateform , which has been "echoed" in PHP using JavaScript function?
See code below

<?php 
if(isset($_SESSION['email'])){

echo"You are looged in as ".$_SESSION['email']. "</br> ";  
echo' <form action="confirmlogout.php" id"logoutform" method="post">
<input type="submit"id="sub" name="sub" onclick="" value = "LOG OUT" />
</form></br>';
}
else{

echo '<h3>Please fill up registration form, to create user account</h3>
<form action="signup.php" id="signform" method="POST" onSubmit="validate()">
<ul>
<li>Please enter your first name: &nbsp;<input type="text" id="fname" name="fname" autofocus autocomplete="" /><div id="erfname"></div></li>
<li>Please enter your last name: &nbsp<input type="text" id="lname" name="lname" onFocus="validate()" /><div id="erlname"></div></li>
<li>Please enter your flat number: &nbsp<input type="text" id="hno" name="hno" /><div id="erfno"></div></li>
<li>Please enter your house number: &nbsp<input type="text" id="hno" name="hno" /><div id="erhno"></div></li>
<li>Please enter street name: &nbsp<input type="text" id="street" name="street" /><div id="erstreet"></div></li>
<li>Please enter your postcode: &nbsp<input type="text" id="pcode" name="pcode" /><div id="erpcode"></div></li>
<li>Please enter your email address: &nbsp<input type="email" id="email" name="email" /><div id="eremail"></div></li>
<li>Please create your password: &nbsp<input type="password" id="pwd1" name="pwd1" /><div id="erpwd1"></div></li>
<li>Please repeat your password: &nbsp<input type="password" id="pwd" name="pwd" /><div id="erpwd"></div></li>
</ul>
<input type="submit" id="submit" name="submit" onSubmit="validate()" value = "Submit" />

</form>
  <a href="log_in.php">Or log in, if you are already registered</a>';
}
?>

Yes, sure. I dont see why. When you access this page, the PHP engine converts it to html markup and sends it back to the browser. So I dont see why the concern about the PHP echo'ing.

I must add as well, make sure you're not relying solely on javascript for your data validation. It should really only be used for user experience and that is all. Always do your final data validation server side with PHP.

Thank you for your response. Everething is working. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.