0

hello everybody i have a form where require user email to be submit, for it i have made client side behavior, if email field is empty js alert the following currend is alert, but i want to show in popup (alert window) a div who allow users to login in page the div content html and php maybe it will content css too.

<form action="<?php echo $editFormAction; ?>" method="POST" name="formulaireajout" class="formulaireajout" id="formulaireajoutid" onSubmit="MM_validateForm('clientmail','','RisEmail');return document.MM_returnValue">
<input name="client" type="text" id="clientmail" value="<?php echo $_SESSION['MM_Username'];?>">
         <input name="addtocart" type="submit" id="submittocart"  value="ADD TO CART">
         <input type="hidden" name="MM_insert" value="formulaireajout">
        </form>
        <-- java script -->
        <script src="../scripts/jquery.js" type="text/javascript"></script>
<script src="scripts/lightbox.js" type="text/javascript"></script>
<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 == '');
} }
</script>

and here is the div who i want to show in popup window

<div id="myaccount">
<form name="loginform" method="POST" action="<?php echo $loginFormAction; ?>">
  <label for="email">Email</label>
   <input type="text" name="email" id="email"><br>
  <label for="pass">Password</label>
  <input type="password" name="pass" id="pass">
  <input type="submit" name="valid" id="valid" value="Log In">
</form></div>
5
Contributors
13
Replies
56
Views
3 Years
Discussion Span
Last Post by chrisschristou
0

hello everybody i have a form where require user email to be submit, for it i have made client side behavior, if email field is empty js alert the following currend is alert, but i want to show in popup (alert window) a div who allow users to login in page the div content html and php maybe it will content css too.

That's quite a sentence - I ran out of breath reading it. So am I right in thinking you want a dialog box to popup (with a login form in it) if the email field is empty? In addition, you want the content of the popup to be styled.

If so, you can use one of hundreds of dialogs (jqueryUI, bootstrap, alertjs...):

https://www.google.co.uk/search?q=js+dialog&oq=js+dialog&aqs=chrome..69i57j0l5.4605j0j7&sourceid=chrome&espv=210&es_sm=93&ie=UTF-8

I'm not sure what you want from us. A recommendation as to the 'best!' dialog to use?

0

Hi,
use this code

<!DOCTYPE html>
<html>
<body>

<p>Click the button to display an alert box.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction()
{
window.alert("I am an alert box!");
}
</script>

</body>
</html>

more u want refer to w3schools...

0

exactly it what i want a dialog box to popup (with a login form in it) if the email field is empty, you can check my script on my post it alert a message, but i want a dialog box. :) prompt()

Edited by chrisschristou

0

OK, so which js script/library are you using for the dialog box? Have you decided on one yet?

0

normal i use jquery to do some calculation as you know on my preview post, and i believe jquery is litle easy. :)
on my post you can see i posted a java/script script when user submit if field email is empty it alert a error dialog. but the javascript code is generated in dreamweaver

0

js is IDE independent. It doesn't matter if you used Notepad even. OK, third time of asking. Which library's dialog are you using/going to use? If you have no idea, then start researching and looking at different examples on the internet - then come back if you're still stuck. I can't see how we can help unless you decide upon a dialog / modal form / lightbox / thickbox / whateverbox!

0

Okay. So do it. Just run the dialog where you have the alert. I'm not sure what you want us to do.

Are you sure that one will allow HTML (your login form into it) - it looks like images only.

Edited by diafol

0

i gave the link ust for exemple i used just form image and what i want is to allow HTML (MY LOGIN FORM), it is for what i'm here.

0

Please understand we are trying to help here but you need to be more specific as diafol suggests. You also need to try. Copying and pasting code and/or links if not helpful especially when we follow those links, come back to you with specific questions and then you indicate that the link was not really the product you intend to use. So then we feel like we are wasting time.

It helps when you can post clean, organized relevant code. Tell us what errors you are experiencing.

If you ask general questions, you are going to get general guidance and advice. Its unlikely that someone is going to simply go off and code a solution for you.

I'm taking the time to write all of this because you are a valued member.

Don't be upset if other members start to loose interest. You have to understand we are volunteers and have tons of other things to do people to see.

I hope this helps.

0

thank you for all and I'm sorry to put you in a difficult situation, i undestund your place,
i have complete the work in css and jquery the dialog box apear and user can login but i have a link which points to dialog box <a href="#login-box" class="login-window">Login / Sign In</a>
AND here is a javascript who check if thsi field is empty on submit <input name="client" type="text" id="clientmail" value="<?php echo $_SESSION['MM_Username'];?>"> onSubmit="MM_validateForm('clientmail','','RisEmail');return document.MM_returnValue">
the on submit if the field is empty it alert an error on the picrure 5a92c8e256ba4e51ca8ffda6433b7ecb
sincerely i would like you to edit this code.
i don't want it to alert error but point to link who show the dialog box

<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 == '');
} }
</script>
0

Stay away from dreamweaver, you're learning bad habits there. There's a rather nice library called jsparsely.

Take a look.

Edited by iamthwee

0

i know it is bad way but this part of generated code is usefull for me and would just to don't aler error but to points to link

     } } } 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 == '');
} }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.