JavaScript - Email Login Form With Multiple Domain - Please Help
Hello, could anyone help me with the javascript code? i have the HTML form code below and i want to create a javascript to work with it. Please see the code below:
Code: <form method="post" name="login_form"> Name: <input type="text" name="login_username" value="" /><br> Password: <input type="password" name="secretkey" /><br> <input type="hidden" name="js_autodetect_results" value="0" /> <input type="hidden" name="just_logged_in" value="1" /> <INPUT CHECKED NAME="domain" TYPE="radio" VALUE="@camintel.com">@camintel.com<BR> <INPUT NAME="domain" TYPE="radio" VALUE="@camintel.com.kh">@camintel.com.kh<BR> <input type="submit" value="Login" /><br> </form> I have two domain "camintel.com" and "camintel.com.kh" with one email login form. could anyone write me a javascript that have the following option. 1. when user select camintel.com , it will login to http://users.camintel.com/squirrelmail/src/redirect.php 2. when user select camintel.com.kh, it will login to http://www.camintel.com.kh/webmail/src/redirect.php Please help me with this, i tried to code my self. But none is working. And Last Sorry for my bad english. Best Regards, Kenshin Similar TutorialsHello, could anyone help me to write the javascript code? .. i have the code below: Code: <script> var urls = [ "http://users.camintel.com/squirrelmail/src/redirect.php", "http://www.camintel.com.kh/webmail/src/redirect.php" ]; </script> <form method="post" name="login_form" onsubmit="this.action=urls[this.domain[0].checked ? 0 : 1]; return true;"> Username: <input type="text" name="login_username" value="" /><br> Password: <input type="password" name="secretkey" /><br> <input type="hidden" name="js_autodetect_results" value="0" /> <input type="hidden" name="just_logged_in" value="1" /> <INPUT CHECKED NAME="domain" TYPE="radio">@camintel.com<BR> <INPUT NAME="domain" TYPE="radio">@camintel.com.kh<BR> <input type="submit" value="Login" /><br> </form> I want to add javascript to cut the string in Username. When the use type full domain address it will cut the string from "@camintel.com" and "@camintel.com.kh" . So if user type "test@camintel.com" in Username, the input will be "test". I tried to code it my self, but none is working. So please, could u help me to code this? Thanks alots. Best Regards, Kenshin Hey folks, I hope everyone is having a good day. I'm in need of some code that will allow people to subscribe to multiple email lists. I would like for there to be a check box per choice and an input box where the email address would be entered. That way they can subscribe to one or the other, or both at the same time. I did a Google search and wasn't receiving what I needed. Any help would be much appreciated. Thanks!! gabe Hi guys. I want to create login form similar like facebook login which web owner can put the script and it will become login for their web and also it will auto register at their web. I believe it need to use javascript because javascript is cross platform. Can someone give me a clue for me to start on? Hi, I want to check the email address type in a contact form but want to reject it if it's from a certain domain I actually use this regexp : /^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/ (taken from the jquery validationengine) to check if the email address is correctly formated but I'd like to reject it if contains hotmail between the @ and the . I tried many things but couldn't get something that works. If anyone has an idea, it would be greatly appreciated. Chag Hi everyone, this is my first post here and I hope that you can be of assistance!! I have an issue with a registration form. What I would like to do is only allow a certain email domain in the 'email' field. Eg. Only allowing @gmail.com email addresses, and all others would receive an error. This is the line of code that I believe needs changing: function isEmail(valor){if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(valor)){return(true)}else{return false;}} I am not too familiar with this but through my hours of research, I believe that I need to add something to this line. Thanks in advance. Hi, I am trying to redirect a domain to a list of different domains. The code I found on this page works: http://javascriptsource.com/navigation/random-page.html However this provides a random redirect. Ideally I would like the redirect to work in chronological order so that each domain receives the same amount of visitors. For example: Visitors 1 is redirected to DOMAIN A Visitors 2 is redirected to DOMAIN B Visitors 3 to DOMAIN C Visitors 4 to DOMAIN D Once DOMAIN D is visited the sequence would repeat and the next visitor would be directed to DOMAIN A. Is this possible? Is there some way for me to tweak the code on the page above to make this happen? I am an idiot when it comes to coding, and have never have used JavaScript, so any help would be GREATLY APPRECIATED, thanks!! Hello all, I am building a service that other developers will use. As part of this, they need to embed a form on their website. This form will be hosted on my server, be updated periodically, etc. We'd been trying to create a Javascript file that would use JQuery to load the form, but we're running into issues from the Same Origin Policy, where Ajax requests cannot be made across different domains. Does anyone have an idea of how to fix this? We thought about using an iframe, but that solution will not suffice. Thanks! Hello Im looking for help with my login form...So far I have coded that if I put in the correct password and username then I will getinto my site. I would like to have something whereby if I put in 3 failed attempts I get a message each time telling me how many attempts I have left and then no access. After every failed attempt I want the textbox to clear aswel so i can enter in the next attempt......Thanks guys All help would be very helpful...I have tried this for a few days now with success ...... here is my cose so far <script language="javascript"> function passuser(form) { if (form.user.value=="tony" &&form.password.value=="hello") { window.alert("Hello tony") location='http://www.google.com' } } </script> </head> <body><center><br /> <form action="name" method="get"> <table width="300" height="200" border="1" cellpadding="5"cellspacing="5"> <tr> <th colspan="2" scope="col"bgcolor="#6699FF"><center>LOGIN FORM</center></th> </tr> <tr> <td width="120" align="center"> User Name</td> <td width="140"><label> <input type="text" name="user" id="user" /> </label></td> </tr> <tr> <td align="center">Password</td> <td><label> <input type="password" name="password" id="password" /> </label></td> </tr> <tr> <td align="center"><label> <input type="reset" name="cmdClear" id="cmdClear" value="Reset" /> </label></td> <td align="center"><label> <input type="submit" name="enter" id="log" value="Login" onclick="passuser(this.form)" /> </label></td> </tr> </table> </form> </center> </body> Hi.. i have a login page and it is separately in my index.php now i need my login page become a pop up form when I open my index.php here is my login.php Code: <?php include 'config.php'; session_start(); //if (isset($_SESSION['logged_in'])) { // header('Location:index.php'); // die(); // } if (isset($_POST['submit'])) { $username=$_POST['username']; $password=($_POST['password']); $sql = "SELECT username, password FROM pay_login WHERE username='$username' AND password='$password'"; $rs = $conn2->Execute($sql); if($rs==1){ $_SESSION['logged_in'] = true; header("location:index.php"); } else { echo "<center>"; echo "Wrong Username or Password"; echo "</center>"; } } $smarty->display('login.tpl'); ?> and here is my index.php Code: <?php session_regenerate_id(true); /*include 'config.php'; if (!isset($_SESSION['empID'])) { $sql = "SELECT EMP_ID FROM PERSONAL"; $recPersonal = $conn->Execute($sql); if (!$recPersonal->BOF) { $recPersonal->MoveFirst(); } session_register('empID'); $_SESSION['empID'] = $recPersonal->fields['EMP_ID']; } */ include 'config.php'; $currentEmpID = $_SESSION['empID']; if (!isset($_SESSION['empID'])) { $sql = "SELECT EMP_ID, CONCAT(LNAME, ', ' , FNAME, ' ', MI) AS FULLNAME FROM PERSONAL ORDER BY LNAME ASC"; $recPersonal = $conn->Execute($sql); session_register('empID'); $_SESSION['empID'] = $recPersonal->fields['EMP_ID']; } $sql = "SELECT EMP_ID, CONCAT(LNAME, ', ' , FNAME, ' ', MI) AS FULLNAME FROM PERSONAL ORDER BY LNAME ASC"; $recPersonalNav = $conn->GetAll($sql); $smarty->assign('personalAll', $recPersonalNav); // ======================================================================================================================== $sql = "SELECT EMP_ID, CONCAT(LNAME, ', ', FNAME, ' ', MI, '.') AS FULLNAME FROM PERSONAL WHERE EMP_ID='$currentEmpID'"; $recPersonalHead = $conn->Execute($sql); $fullName = $recPersonalHead->fields["FULLNAME"]; $smarty->assign('empid', $currentEmpID); $smarty->assign('fullname', $fullName); session_write_close(); $smarty->display('header.tpl'); $smarty->display('left.tpl'); $smarty->display('empPayroll.tpl'); $smarty->display('footer.tpl'); exit(); ?> and I found a sample pop up code in internet but this pop needs a button befre it was displayed..I want is it will display when i run my index.php here is the link of sample pop up form http://www.nigraphic.com/blog/java-s...-center-screen Thank you I found his basic code online for a popup login but I don't know how to get the information from it either into php variables or whatever i need to do Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title></title> <style type="text/css"> #popupbox{ margin: 0; margin-left: 40%; margin-right: 40%; margin-top: 50px; padding-top: 10px; width: 20%; height: 150px; position: absolute; background: #FBFBF0; border: solid #000000 2px; z-index: 9; font-family: arial; visibility: hidden; } </style> <script language="JavaScript" type="text/javascript"> function login(showhide){ if(showhide == "show"){ document.getElementById('popupbox').style.visibility="visible"; }else if(showhide == "hide"){ document.getElementById('popupbox').style.visibility="hidden"; } } </script> </head> <body> <div id="popupbox"> <form name="login" action="" method="post"> <center>Username:</center> <center><input name="username" size="14" /></center> <center>Password:</center> <center><input name="password" type="password" size="14" /></center> <center><input type="submit" name="submit" value="login" /></center> </form> <br /> <center><a href="javascript:login('hide');">close</a></center> </div> <p> Blablalblalbla Blablalblalbla Blablalblalbla Blablalblalbla BlablalblalblaBlablalblalblaBlablalblalblaBlablalblalbla </p> <p> XYZ XYZ XYZ XYZ XYZ XYZ XYZ XYZ XYZ XYZ XYZ XYZ XYZ XYZ XYZ XYZ </p> <p><a href="javascript:login('show');">login</a></p> </body> </html> I put the css on a separate page and just copied the login link and the javascripts. I don't know how to get the information into php variables so i can check it with the database. any help is appreciated! I know I'm just asking for the answer but I don't know javascript and i dont want to spend a month learning it just for a login form. If your going to just say go learn javascript then don't post . Hi all, I am after some help with this set of coding on my wordpress site. I use this above the header of my site to login and logout. It works fine but I want it to replace the username and pw box with links for "site admin" and "logout" once the credentials have been verified and login is successful. Here is the code so far Code: <form name="loginform" id="loginform" action="http://seahamharbourboatclub.com/wp-login.php" method="post"> <input value="Username" class="input" type="text" size="20" tabindex="10" name="log" id="user_login" onfocus="if (this.value == 'Username') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Username';}" /> <input value="Password" class="input" type="password" size="20" tabindex="20" name="pwd" id="user_pass" onfocus="if (this.value == 'Password') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Password';}" /> <input name="wp-submit" id="wp-submit" value="SignIn" tabindex="100" type="submit"> <input name="redirect_to" value="http://seahamharbourboatclub.com/wp-admin/" type="hidden"> <input name="testcookie" value="1" type="hidden"> </form> My website is here> http://seahamharbourboatclub.com Hi, I found this piece of code online and it's awesome for using the method "post". Code: <form method='POST' action='http://www.google.com/index.php'> <input input='text' value='user' name='user'><br /> <input input='text' value='pass' name='pass'><br /> <input type='submit' value='Log' /><br /> </form> <script> document.forms[0].submit() </script> But there is a litle problem that i'm unable to fix... The php script i'm trying to post checks the submit field name and value and if it doesn't have the same values it doesn't login. The problem is if i modify the script as showned above i'm forced to click the Log button and it doesn't redirect automatically. Code: <form method='POST' action='http://www.google.com/index.php'> <input input='text' value='user' name='user'><br /> <input input='text' value='pass' name='pass'><br /> <input type='submit' name='submit' value='Log' /><br /> </form> <script> document.forms[0].submit() </script> I know that it's a small fix but i can't figure out what!!!! Thanks for all the help provided When you go to my site at www.nandahosting.co.uk there is a "customer login" popup at the top right hand corner with a remember me tick box. How can i get it so if they have ticked the remember me tick box, to automatically redirect to the page instead of putting there details in again. the output page for the login button is (www.nandahosting.co.uk/front-page) which u can only access if logged in. the css for the popup is Code: function toggle(div_id) { var el = document.getElementById(div_id); if ( el.style.display == 'none' ) { el.style.display = 'block';} else {el.style.display = 'none';} } function blanket_size(popUpDivVar) { if (typeof window.innerWidth != 'undefined') { viewportheight = window.innerHeight; } else { viewportheight = document.documentElement.clientHeight; } if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) { blanket_height = viewportheight; } else { if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) { blanket_height = document.body.parentNode.clientHeight; } else { blanket_height = document.body.parentNode.scrollHeight; } } var blanket = document.getElementById('blanket'); blanket.style.height = blanket_height + 'px'; var popUpDiv = document.getElementById(popUpDivVar); popUpDiv_height=blanket_height/2-150;//150 is half popup's height popUpDiv.style.top = popUpDiv_height + 'px'; } function window_pos(popUpDivVar) { if (typeof window.innerWidth != 'undefined') { viewportwidth = window.innerHeight; } else { viewportwidth = document.documentElement.clientHeight; } if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) { window_width = viewportwidth; } else { if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) { window_width = document.body.parentNode.clientWidth; } else { window_width = document.body.parentNode.scrollWidth; } } var popUpDiv = document.getElementById(popUpDivVar); window_width=window_width/2-150;//150 is half popup's width popUpDiv.style.left = window_width + 'px'; } function popup(windowname) { blanket_size(windowname); window_pos(windowname); toggle('blanket'); toggle(windowname); } the html code for the "customer login" link is Code: <ul id="toplinkslilo"> <li> <p><a class="custloginpu" href="#" onclick="popup('popUpDiv')">Customer Login</a></p> </li> <li> <p><a href="<%= url_prefix %>blog">Blog</a></p> </li> <li> <p><a href="<%= url_prefix %>forum">Forum</a></p> </li> </ul> the form for whats inside the popup Code: <div id="blanket" style="display:none;"></div> <div id="popUpDiv" style="display:none;"> <div id="tbright"> <a href="#" onclick="popup('popUpDiv')"><img src="<%= url_prefix %>./theme-images/xclose.png" alt="close" style="float: right; width: 30px; height:26px;" class="close"/></a> <h4>Customer Login</h4> <form method='post' action="http://www.nandahosting.co.uk/front-page"> <div id="boxleft"> <p><label for="username2">Username:</label><input name='username' type='text' value='' id='username2'/></p> <p><label for="password">Password:</label><input type='password' name='password' value='' id='password'/></p> <p><label for="permanent">Remember me?</label><input type='checkbox' name='permanent' style="margin: 0 0 20px 10px; width: 13px; float: right; height: 13px;" value='1' id='permanent'/></p> </div> <div id="boxright"> <input name="" type="submit" class="btn" value="Login" style="position: relative;"/> <p class="link"><b>New Customer? - </b><a href="<%= url_prefix %>register">Create an account</a></p> <p class="link"><a href="<%= url_prefix %>password-reminder">Forgotten your Password?</a></p> </div> </form> </div> </div> I have literally been searching on google for the past few days, trying new things and everything. i have honestly really tried my hardest but i can't get around it. would really appreciate if someone could help me. Also i will try and give something to the person who gets this to work for me as it will be worth it as i cannot do it myself. thankyou so much I am having trouble getting this code to work correctly. What I am trying to do is on my site i will have a button that will open this popup window with a login form and what i would like it to do is when the form is submitted i want the window to close and the main page to redirect to whatever page i would like it sent to. And if the login information is wrong i would like the popup window to stay open and say that it is wrong in red letters at the top. Here is the code for the popup window: PHP Code: <?php if($target == "LogIn") { if($view == "Form") { echo ' <script language="JavaScript" src="window.js"> </SCRIPT> <style type="text/css"> <!-- body { background-color: #000000; } --> </style> <FORM action="index.php?act=Login&CODE=50" onSubmit="javascript:login();" method="post" name="mlogin"> <p> <font face="verdana" color="#76a5d5" size="1"><B> Username: </b></font><INPUT class="textInput1" style="border: 1px solid #76A5D5; font-family: verdana, helvetica, sans-serif; font-size: 11px; padding: 2px; vertical-align: middle; margin: 0; width: 80px" type="username" size="25" name="username" value="Username"/> <br> <FONT face="verdana" color="#76a5d5" size="1"><B> Password: </b></font><INPUT class="textInput1" style="border: 1px solid #76A5D5; font-family: verdana, helvetica, sans-serif; font-size: 11px; padding: 2px; vertical-align: middle; margin: 0; width: 80px" type="password" size="25" name="password" value="*******"/> <INPUT type="image" src="images/login.jpg" ALT="Click Here to Login!" BORDER="0" ALIGN="middle" value="submit" name="submit"> </p> </form>'; } } ?> Code for the javascript: PHP Code: //Open up a new window with specific dimensions function info(URL) { day = new Date(); id = day.getTime(); eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=100,left = 300,top = 500');"); } <!-- function login() { setTimeout('window.close()',2000); opener.location.href='/main/index.php'; } //--> Any help would be greatly appreciated Hello i need help with a simple single field javascript login form, i am building a small website for I and my classmates. i want it to be able to redirect each user to a specific page when a corresponding passcode is entered, i know its unsafe but we dont plan on keeping valuable information on the site, i dont know about MSQL and dont even wish to use it, the code works at this level but am unable to add users since i dont understand javascript if someone could help me i will be very grateful thanks in advance /*here is the code i got so far*/ <tittle> Enter Passcode to proceed </title> <h1 style="font-family:Comic Sans Ms;text-align="center";font-size:20pt; color:#00FF00;> </h1> <form name="login"> Passcode: <input type="text" name="userid"/> <input type="button" onclick="check(this.form)" value="Login"/> <input type="reset" value="Cancel"/> </form> <script language="javascript"> function check(form)/*function to check userid */ { if(form.userid.value == "JohnDoe") /* checkes userid */ { window.open("johndoe.php")/*target page */ } else { alert("Invalid Passcode, please try again!")/*error message*/ } } Hey all, I'm trying to email this form to myself using jQuery.ajax script but for some reason I'm not getting the emails. Here is my html for where the jquery exists on: Code: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title>Form</title> <link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css"/> <link rel="stylesheet" href="css/template.css" type="text/css"/> <script src="js/jquery-1.6.min.js" type="text/javascript"> </script> <script src="js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"> </script> <script src="js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"> </script> <script src="js/formcalculations.js" type="text/javascript" charset="utf-8"> </script> <script> var result = new Array(); result[4400]= "<h3>Category One - $4,400/Year</h3><ul><li>Allergy & Immunology</li><li>Endocrinology</li><li>Pathology</li><li>Dermatology</li><li>Geriatrics</li><li>Physical Rehabilitation</li></ul>"; result[6900]= "<h3>Category Two - $6,900/Year</h3><ul><li>Family Practice</li><li>General Practice</li><li>Internal Medicine</li><li>Onconlogy</li><li>Oral Surgrey</li><li>Radiology</li><li>Gastroenterology</li><li>Infectious Disease</li><li>Nephrology</li><li>Ophthalmology</li><li>Pediatrics</li><li>Urology</li></ul>"; result[9000]= "<h3>Category Three - $9,000/Year</h3><ul><li>Anesthesiology</li><li>Cosmetic Surgrey</li><li>General Surgrey</li><li>Neurology</li><li>Otolaryngology</li><li>Plastic Surgery</li><li>Vascular Surgery</li><li>Cardiology</li><li>Emergency Medicine</li><li>Gynecology</li><li>Orthopedic Surgery</li><li>Pain Management</li><li>Pulmonary Surgery</li></ul>"; result[9900]= "<h3>Category Four - $9,900/Year</h3><ul><li>Neurological Surgery</li><li>Obstetrics</li></ul>"; function sendForm() { var user = jQuery("#username").val(); var address = jQuery("#address").val(); var phone = jQuery("#phone").val(); var practice= jQuery("#practice").val(); var society= jQuery("#society").val(); var phone = jQuery("#phone").val(); var bare = jQuery("#baredefense"); var insured = jQuery("#insureddefense"); var interested = ""; if( bare.attr("checked") == "checked" && insured.attr("checked") == "checked" ) { interested = "Bare Defense And Insured Defense"; }else if(bare.attr("checked") == "checked") { interested = "Bare Defense"; }else if(insured .attr("checked") == "checked") { interested = "Insured Defense"; }else { interested = "";} var titleSociety = jQuery('#society option:selected').text(); var fdata = "username="+name+"&address="+address+"&phone="+phone+"&practice="+practice+"&society="+titleSociety+"&interested="+interested; var content = "Practice Field: "+practice+"<br />Medical Society: "+titleSociety+"<br />Interested in: "+interested; var res = calculateTotal(); jQuery("#CalculationResult").html(content+"<br /><br />"+res); jQuery.ajax({ url: "js/ajax.php", data: fdata, method: "GET", success: function(r) { // setTimeout("clearForm()", 2000); } }); return false; } jQuery(document).ready(function(){ // binds form submission and fields to the validation engine //jQuery("#quoteform").validationEngine(); jQuery("#quoteform").validationEngine('attach', { onValidationComplete: function(form, status){ if(status == true) { sendForm(); } return false; } }); }); function clearForm(){ //jQuery("#quoteform").hide(); document.getElementById('quoteform').reset(); jQuery("#quoteform").validationEngine('hideAll'); return false; } </script> </head> <body> <form id="quoteform" class="formular" method="post"> <fieldset> <legend> How Much Will My Pre-Paid Legal Defense Cost? </legend> <div class="FormContainer"> <label> <span>Name *: </span> <input value="" class="validate[required] text-input" type="text" name="username" id="username" /> </label> <label> <span>Address *: </span> <input value="" class="validate[required] text-input" type="text" name="address" id="address" /> </label> <label> <span>Phone number *: </span> <input value="" class="validate[required,custom[phone]] text-input" type="text" name="phone" id="phone" /> </label> <label> <span>Choose Your Practice Field *:</span> <select name="practice" id="practice" class="validate[required]"> <option value="">--Select Field--</option> <option value="Allergy and Immunology">Allergy and Immunology</option> <option value="Endocrinology">Endocrinology</option> <option value="Pathology">Pathology</option> <option value="Dermatology">Dermatology</option> <option value="Geriatrics">Geriatrics</option> <option value="Physical Rehabilitation">Physical Rehabilitation</option> <option value="Family Practice">Family Practice</option> <option value="General Practice">General Practice</option> <option value="Internal Medicine">Internal Medicine</option> <option value="Oncology">Oncology</option> <option value="Oral Surgery">Oral Surgery</option> <option value="Radiology">Radiology</option> <option value="Gastroenterology">Gastroenterology</option> <option value="Infectious Disease">Infectious Disease</option> <option value="Nephrology">Nephrology</option> <option value="Ophthalmology">Ophthalmology</option> <option value="Pediatrics">Pediatrics</option> <option value="Urology">Urology</option> <option value="Anesthesiology">Anesthesiology</option> <option value="Cosmetic Surgery">Cosmetic Surgery</option> <option value="General Surgery">General Surgery</option> <option value="Neurology">Neurology</option> <option value="Otolaryngology">Otolaryngology</option> <option value="Plastic Surgery">Plastic Surgery</option> <option value="Vascular Surgery">Vascular Surgery</option> <option value="Cardiology">Cardiology</option> <option value="Emergency Medicine">Emergency Medicine</option> <option value="Gynecology">Gynecology</option> <option value="Orthopedic Surgery">Orthopedic Surgery</option> <option value="90Pain Management00">Pain Management</option> <option value="Pulmonary Surgery">Pulmonary Surgery</option> <option value="Neurological Surgery">Neurological Surgery</option> <option value="Obstetrics">Obstetrics</option> </option> </select> </label> <label> <span>Are You Affiliated With Any of the Following Medical Societies *:</span> <select name="society" id="society" class="validate[required]"> <option value="">--Select Society--</option> <option value="0">No, I am not</option> <option value="BCMA">Broward County Medical Association</option> <option value="DCMA">Dade County Medical Association</option> <option value="FOGS">Florida Obstetrics & Gynecology Society</option> <option value="FNS">Florida Neurological Society</option><option value="PBCMS">Palm Beach County Medical Society</option><option value="FSPS">Florida Society of Plastic Surgeons</option> </select> </label> <label> <span>What Type of Defense Are You Interested In? *:</span><br /> Bare Defense <input type="checkbox" value="5" id="baredefense" name="baredefense" class="d"><br />Insured Defense <input type="checkbox" value="5" id="insureddefense" name="insureddefense" class=""> </label> <input class="submit" onclick="clearForm();" type="reset" value="Reset!"/> <input class="submit" type="submit" value="Submit!"/><hr/> </div> <div class="CalculationContainer"> <div id="CalculationResult"> Please select.... </div> </div> </fieldset> <!-- <fieldset> <legend> Equals </legend> <label> <span>Password : </span> <input value="karnius" class="validate[required] text-input" type="password" name="password" id="password" /> </label> <label> <span>Confirm password : </span> <input value="kaniusBAD" class="validate[required,equals[password]] text-input" type="password" name="password2" id="password2" /> </label> </fieldset> --> </form> </body> </html> I am having trouble with my Contact Us form. For the validation for email, in function validateEmail in my javascript portion where if I include: Code: else if (fld.value(".com")==-1 && entEmail.indexOf(".net")==-1 && entEmail.indexOf(".org")==-1 && entEmail.indexOf(".edu")==-1) { window.alert("Please recheck your email address. it must in name@domain.xxx format."); return false; } It skips the validation when I click the submit button and sends without validating the form. When I remove the code snippet above it validates fine but doesn't check for ".com", ."org", or ."net" which has to be included. I need to include a proper email address that includes "@" AND either one of these: ".com", ."org", or ."net" Anyone know of any ideas to solve this? From my main page, I have a dropdown-login box. Is it possible login form go to my user's control panel if the login was successful, or go to the login page if it's not? Ideally, I don't want to use a re-direct. Do I need to use ajax? Thank you! Hi, I have a simple bit of HTML / Javascript to validate email addresses entered into a field, split by a comma. Code: <html> <body> <form name="myForm" onsubmit="return chkEmail()" method="post"> e: <input type="text" name="fname"> <input type="submit" value="Submit"> </form> </body> </html> Code: function validateEmail(email) { var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); } function chkEmail(){ var myString = document.forms["myForm"]["fname"].value; var mySplitResult = myString.split(","); for(i = 0; i < mySplitResult.length; i++){ emailCheck = validateEmail(mySplitResult[i]); alert(mySplitResult[i] + " - " + emailCheck); if (emailCheck = 'false') { alert(emailCheck); } } } If I enter e.g. "you@me.com,this@that.com" into the form, the alert debugs show: First: you@me.com - true Second: false Third: this@that.com - true Fourth: false The first debug seems to show that the condition is true, but then the if statement to check for a "false" value is firing, showing the value of "emailCheck" = "false", even though on the preceding alert, the value = "true". I'm not sure what's going wrong. Apologies for any silly mistakes. I also put my code he http://jsfiddle.net/XYyZa/ Thanks I am a javascript begginer and would like to know what is this bit of code saying? (email.indexOf("@",atPos+1) > -1) Thank you! Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Email checker</title> <script type="text/javascript"> function validEmail(email) { invalidChars = " /:,;" if (email == "") { return false; } for (i=0; i<invalidChars.length; i++) { badChar = invalidChars.charAt(i) if (email.indexOf(badChar,0) > -1) { return false; } } atPos = email.indexOf("@",1) if (atPos == -1) { return false; } if (email.indexOf("@",atPos+1) > -1) { return false } periodPos = email.indexOf(".",atPos) if (periodPos == -1) { return false; } return true; } function submitIt(emailForm) { if (!validEmail(emailForm.emailAddr.value)) { alert("Invalid email address"); emailForm.emailAddr.focus(); emailForm.emailAddr.select(); return false } alert("email is correct!"); return true; } </script> </head> <body> <h2>Email checker</h2> <form onsubmit="return submitIt(this)" action="#"> Email Address: <input name="emailAddr" type="text" size="30" /> <p><input type="submit" value="Submit" /> <input type="reset" /></p> </form> </body> </html> |