Topic: A Validation question

Can someone please tell me how I can make this line validate:

<form id="login" name="login" method="post" action="login.php?action=in" onsubmit="return process_form(this)">

It won't accept the name (name) but it is required for the rest of the form which I have posted below:

            <form id="login" name="login" method="post" action="login.php?action=in" onsubmit="return process_form(this)">
    <p>

     <input type="hidden" name="form_sent" value="1" />
     <input type="hidden" name="redirect_url" value="index.php" />
     <span class="login-boxes"><?php echo $lang_common['Username'] ?>:</span>
     <input type="text" style="height: 14px;" name="req_username" size="12" maxlength="25" />
     <span class="login-boxes"><?php echo $lang_common['Password'] ?>:</span>

     <input type="password" style="height: 14px;" name="req_password" size="12" maxlength="16" onkeypress="if(event.keyCode==13) document.login.submit()" />
      <a class="login-name" href="#" onclick="document.login.submit(); return true">Login</a> | <a class="login-name" href="register.php">Register</a>
    </p>

   </form>

Thanks for the help.

Bingiman

2

Re: A Validation question

It's the id that matters. Should work fine without name.

Re: A Validation question

neh, it doesn't work without the name Matt.

Re: A Validation question

This is my complete login:

<?php
 
// Show login if not logged in
if($pun_user['is_guest'])
{
    if(!isset($focus_element) || (isset($focus_element) && !in_array('login', $focus_element)))
    {
 
    // Load the language files
    require PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
    require PUN_ROOT.'lang/'.$pun_user['language'].'/login.php';
 
    // Try to determine if the data in HTTP_REFERER is valid (if not, we redirect to index.php after login)
    $redirect_url = (isset($_SERVER['HTTP_REFERER']) && preg_match('#^'.preg_quote($pun_config['o_base_url']).'/(.*?)\.php#i', $_SERVER['HTTP_REFERER'])) ? htmlspecialchars($_SERVER['HTTP_REFERER']) : 'index.php';
 
    $required_fields = array('req_username' => $lang_common['Username'], 'req_password' => $lang_common['Password']);
 
?>
<script type="text/javascript">
<!--
function toggle_lsup() {
    var smu = document.getElementById("login_form");
    var smutxt = document.getElementById("login_form_text");
    if (smu.style.display == "none") {
        smu.style.display = "block";
        smutxt.innerHTML = "Close Panel";
    } else {
        smu.style.display = "none";
        smutxt.innerHTML = "Login Panel";
    }
}
//-->
</script>


<div id="loginbox"><a href="javascript:void(0)" onclick="toggle_lsup();"><span id="login_form_text">Login Panel</span></a>
<div id="login_form" style="display: none;">
            <form id="login3" name="login3" method="post" action="login.php?action=in" onsubmit="return process_form(this)">

    <p>

     <input type="hidden" name="form_sent" value="1" />
     <input type="hidden" name="redirect_url" value="index.php" />
     <span class="login-boxes"><?php echo $lang_common['Username'] ?>:</span>
     <input type="text" style="height: 14px;" name="req_username" size="12" maxlength="25" />
     <span class="login-boxes"><?php echo $lang_common['Password'] ?>:</span>

     <input type="password" style="height: 14px;" name="req_password" size="12" maxlength="16" onkeypress="if(event.keyCode==13) document.login3.submit()" />
      <a class="login-name" href="#" onclick="document.login3.submit(); return true">Login</a> | <a class="login-name" href="register.php">Register</a>
    </p>

   </form>

</div></div>

 
<?php
    }
}

5

Re: A Validation question

What exactly doesn't work? That is the login/header block, isn't it?

6

Re: A Validation question

That looks like you need to tweak the javascript. I'm naff at js though. big_smile Elbecko might be the one to ask on that subject. smile

Re: A Validation question

Clicking on login does not work. As it is now it works but won't validate as long as <form name="login3" is there. It is a modified login that sites on the header. If I substitute the URL with the input then it works but I want it to be a text link and not an input button. If however I can get the register text link as a button, then that would be great. Have I lost you yet.

Bingiman

8

Re: A Validation question

bingiman wrote:

Have I lost you yet.

Completely. big_smile

Shouldn't the form id be login_form rather than the div id?

Re: A Validation question

no, because if you look at the code you'll notice that I am using a javascript open/close function and this is why the div has that id. The login box appears only when clicked on in the header. As I mentioned, the code I posted above works. The only problem is that it does not validate. It tells me the error is the form name.

Re: A Validation question

I found a way around it. I am just going to use the input instead of the URL's like this:

<input type="submit" name="login" value="<?php echo $lang_common['Login'] ?>" tabindex="3" />|<input type="button" onclick="parent.location='register.php'" name="register" value="<?php echo $lang_common['Register'] ?>" tabindex="3" />

This validates.

11

Re: A Validation question

Well, I'm not much use with this one. This is the form line I have in mine, and it works as expected:

<form id="login" method="post" action="<?php echo $forumuri ?>login.php?action=in" onsubmit="return process_form(this)">