i have a registration page where a user fills a form and i display an error
message if a validation message needs to be displayed which i have written
in php. everything works fine. the way the form is made presently is there
is a huge amount of information relating to general information about the
form and its terms and conditions which is compulsory. so if i have to
display any validation message the user has to scroll the page from the top
again all the way till they see the validation message.

i have used relative linking as it is done in html, so that the user does
not have to scroll from the top of the page, rather the page stops where i
want it to so the user see the message and does not have to scroll the page.

following are the 2 methods i have used and both of them work fine. however
in method 2 as it is based on javascript and if
javascript is turned off the relative linking will not work and the user
will have to scroll from the top of the page again and i have tested this
myself.

method 1

<form action="<?php echo $_SERVER["PHP_SELF"]; ?>#indrel" method="POST"
id="test2" name="registrationform" >
<a name="indrel"></a>

 if($error)
 {
 echo $error;
 }

method 2

<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST" id="test2"
name="registrationform" >
<a name="indrel"></a>

 if($error)
 {
 echo ("
 <script language='javascript' type='text/javascript'>
 window.location.href='http://website.com/filename.php#indrel'
 </script>
 ");

 echo $error;
 }

please comment if method 1 is correct in terms of the syntax of the form tag
if it is correct or not though i know this method is working the way i want
it to, i wanted to confirm before i implement it for my website.

please advice.

thanks.

Reply via email to