hello every daniweb friend.
i have a javascript code which check if a field is empty onSubmit it alert a error line 15 but i don't it to alert i want to tag this link to open this html link <a href="#login-box" class="login-window">Login / Sign In</a> and i don't have no idea for js link (tag) navigstion

<script type="text/javascript">
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

hello friend
can someone help to replace the alert to redirection to this link <a href="#login-box" class="login-window">Login / Sign In</a> please ???

Instead of alert, you want to redirect the user? Did you try..


thank very much fo reply.
yes exactly i want to redirect "#login-box" display my light box div who content login form.
i tried the below and it don't work.

if (errors) window.location.href="#login-box";
} }

and this one

if (errors) window.location.href="#login-box";
    document.MM_returnValue = window.location.href="#login-box";
} }

i tried this only this had diference because is try to refresh the navigator.

if (errors) window.location.href="#login-box";
    document.MM_returnValue = (window =='');
} }

can someone help me here please???

post the code for your login lightbox script

thank you for the reply
here is the jquery code of lighbox save as poouplogin.js

$(document).ready(function() {
$('a.login-window').click(function() {

            //Getting the variable's value from a link 
    var loginBox = $(this).attr('href');

    //Fade in the Popup

    //Set the center alignment padding + border see css style
    var popMargTop = ($(loginBox).height() + 24) / 2; 
    var popMargLeft = ($(loginBox).width() + 24) / 2; 

        'margin-top' : -popMargTop,
        'margin-left' : -popMargLeft

    // Add the mask to body
    $('body').append('<div id="mask"></div>');

    return false;

// When clicking on the button close or the mask layer the popup closed
$('a.close, #mask').live('click', function() { 
  $('#mask , .login-popup').fadeOut(300 , function() {
return false;

Here is the HTML form

<div id="pouplogin"><div id="login-box" class="login-popup">
<a href="#" class="close"><img src="close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>
  <form name="loginform"  class="signin" method="POST"action="<?php echo $loginFormAction; ?>">
        <fieldset class="textbox">
        <label class="username">
        <span>User email</span>
        <input id="username" name="username" value="" type="email" autocomplete="on" placeholder="Email">
        <label class="password">
        <input id="password" name="password" value="" type="password" placeholder="Password">
        <input type="submit" name="submit" class="submit" value="Log in">
        <input type="submit" name="submit" id="submit" value="Submit">
  <a class="forgot" href="#">Forgot your password?</a>

the light box is show when to this link: <a href="#login-box" class="login-window">Login / Sign In</a>

instead of alert you'd want to call the same function your login button calls

either you cant trigger the click function for that button
or create a login function using the code from the login button and then just call it
some thing like that
and replace alert with login()

hello friends,
i have update my code i tryed it but i have this in searchbar http://www.locahost.com/page/document.getElementById('login-box')
this is the script

<script type="text/javascript">
function showloginbox()
var client=document.forms["formulaireajout"]["client"].value;
if (client==null || client=="")
  return false;

and here is the html form <form action="<?php echo $editFormAction; ?>" method="POST" name="formulaireajout" class="formulaireajout" id="formulaireajoutid" onSubmit="return showloginbox()">

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.