JavaScript - Setting User Inputed Date.
I am trying to make the date that is entered by the user within the pickDate text box be +2 days ahead of the current date.
Code: function reserveDate(){ var mydate = new Date(); var theyear = mydate.getFullYear(); var themonth = mydate.getMonth()+1; var thetoday = mydate.getDate()+2; if (document.forms[0].pickDate.value <= thetoday) window.alert("Reservations need to be two days in advance."); } input type="text" name="pickDate" onblur="return reserveDate(this.value);"> Similar TutorialsOkay, so I have a canvas, and I want the user to be able to copy an image url and paste it into an input box, that will then set it as the canvas background image. Does anyone know how I can do this? I was thinking about using the OnChange method in the text input, but I cannot find any help with that online. My current Canvas Background is (In <head><script>) Code: var imgObg = new Image(); imageObj.src = "images/bg.png"; And my text input is Code: <form name="input" action="" method="get"> <input type="text" id="textboxBG" onchange="??" /> <input type="submit" value="Submit" /> </form> If you need more code, or would like to help me out more in depth, I would gladly paypal you a little money. I know this can't be too difficult! I REALLY want this done! I'm working with datepickers to select a date range for my travel site (so they are a departure date and a return date). There are two datepickers and I can't get the min date on the first calendar set to today, and I also can't figure out how to get the date fields to clear if the user clicks the browsers refresh button - please help! Here's the javascript code I'm currently trying to run: $(function() { var dates = $("#datepicker1, #datepicker2").datepicker({ defaultDate: '', minDate: '+0m +0w +0d', // this isn't working to set the earliest selectable date to today maxDate: '+0m +0w +365d', // but oddly enough this one works to make sure users can't select a date farther than a year out numberOfMonths: 2, beforeShow: function() { var other = this.id == "from" ? "#datepicker2" : "#datepicker1"; var option = this.id == "from" ? "maxDate" : "minDate"; var selectedDate = $(other).datepicker('getDate'); $(this).datepicker("option", option, selectedDate); } }).change(function(){ var other = this.id == "from" ? "#datepicker2" : "#datepicker1"; if($('#datepicker1').datepicker('getDate') > $('#datepicker2').datepicker('getDate')) $(other).datepicker('setDate', $(this).datepicker('getDate')); }); }); // this is the function I wrote to try to clear the fields when browser refresh is clicked but it doesn't do anything function clearInp() { document.getElementById('datepicker1').value = ""; document.getElementById('datepicker2').value = ""; } Here's the corresponding HTML code: <form method="POST" name="myForm2" class="calendars"> <input id="datepicker1" type="text" name="departure_date" class="dates" size="15" maxlength="25" /> to <input id="datepicker2" type="text" name="return_date" class="dates" size="15" maxlength="25" /> </form> Thanks in advance! Hi folks. Looking to see if anyone could tell me where I'm going wrong with this script... I'm trying to have a field automatically filled with the day of the week ("Monday", "Tuesday", "Wednesday" and so on), upon the user selecting a date from the datepicker jQuery. If this isn't clear, I'll clarify further down the page. Here is the script: Code: <script type="text/javascript"> jQuery(document).ready(function($){ $('input[name="item_meta[428]"]').change(function(){ var d = $('input[name="item_meta[428]"]').val(); var n = new Date(d).getDay(); if(n == 0) val v = 'Sunday'; else if(n == 1) val v = 'Monday'; else if(n == 2) val v = 'Tuesday'; else if(n == 3) val v = 'Wednesday'; else if(n == 4) val v = 'Thursday'; else if(n == 5) val v = 'Friday'; else if(n == 6) val v = 'Saturday'; $('input[name="item_meta[429]"]').val(v).change(); }); }); </script> I'm basically trying to say, if the user selected today (15/05/2012) in the field 428 it would fill the field 429 with "Tuesday". Again, if the user selected 18/05/2012 in the field 428 then it would automatically fill field 429 with "Friday". It's being done to work in conjunction with a wordpress plugin called Formidable Pro hence the item_meta[428] etc. Any assistance would be greatly appreciated. Sam. Not sure if this is possible in javascript: I'm looking for two different dates (bill date and due date) on an invoice that are captured by OCR. If one of them exists, but the other does not, I want the empty field to be 14 days before (or after) the other. For example: if the bill date is 7/27/2010 and the due date was not captured, I want to set the due date as 8/10/2010 (14 days after the bill date). If the due date was captured as 8/10/2010, but the due date is blank, I want to assign the bill date as 7/27/2010 (14 days before the due date). if both dates have values, do nothing. Thanks. I have a drop down menu where people can select a month, day and year. Based on their selection, I want to show them an image. If their selection is >= July 26, 2010 but <= July 25, 2011, show the red image; If their selection is >= July 26, 2011 but <= July 25, 2012, show the white image; If their selection is >= July 26, 2012 but <= July 25, 2013, show the blue image; If their selection is >= July 26, 2013 but <= July 25, 2014, show the yellow image; I don't know how to compare a selected date to a range of dates like this. Hi, I've inherited a Form which calculates a future date based on a calculation and then inserts today's date and the future date into a database. The day part of the date is formatted as a number. This is fine, but up to 9 the numbers display in single figures with no leading zeros. I want them to display leading zeros (e.g. 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11... 30, 31) So; 1/12/2010 is NOT wanted 01/12/2010 IS wanted The inherited code originally set the Month names as "Jan", "Feb" etc, and it was easy to kludge these to 01, 02... 12, but I suspect there's a more elgant solution to this as well, this bit of the code works so it's not as vital to neaten this but my database needs dd/mm/yyyy format (it's a third party email program). Code: </script> <script type="text/javascript"> var todaysDate = new Date(); function updateExpiryDate(){ var weeklyMileage = document.getElementById('AvWeeklyMileage').value; var expiryDate; var weeks = 0; var expiryDateString = ''; if (!isNaN(parseInt(weeklyMileage))){ weeks = 700/weeklyMileage; expiryDate = new Date(todaysDate.getTime() + (1000 * 3600 * 24 * 7 * weeks)); var expiryDateString = expiryDate.getDate() + '/' + getMonthString(expiryDate.getMonth()+1) + '/' + expiryDate.getFullYear(); document.getElementById('expiryDate').innerHTML = expiryDateString; document.getElementById('ShoeExpiryDate').value = expiryDateString; } else { document.getElementById('ShoeExpiryDate').value = ''; document.getElementById('expiryDate').innerHTML = 'Please enter a valid weekly average mileage' } } function getMonthString(monthNumber){ var monthString = ""; switch(monthNumber){ case 1: monthString = "01"; break; case 2: monthString = "02"; break; case 3: monthString = "03"; break; case 4: monthString = "04"; break; case 5: monthString = "05"; break; case 6: monthString = "06"; break; case 7: monthString = "07"; break; case 8: monthString = "08"; break; case 9: monthString = "09"; break; case 10: monthString = "10"; break; case 11: monthString = "11"; break; case 12: monthString = "12"; break; default: // do nothing; } return monthString; } function setTodaysDate(){ var todaysDateString = todaysDate.getDate() + '/' + getMonthString(todaysDate.getMonth()+1) + '/' + todaysDate.getFullYear(); document.getElementById('todaysDate').innerHTML =todaysDateString; document.getElementById('DateOfPurchase').value = todaysDateString; } Can someone point me in the right direction please? Hello, I really need your help with one. How can I use the following code below to save the date from my popup window datepicker back into a var and relay it back onto its parent page? I can't seem to figure this out: Code: <html> <head> <script> function open_cal() { var str_html = "" + "<!DOCTYPE html>\n" + "<html lang=\"en\">\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>CALENDAR</title>\n" + "<link href=\"jq/jquery-ui.css\" rel=\"stylesheet\" type=\"text/css\">\n" + "<script src=\"jq/jquery.min.js\" type=\"text/javascript\"></" + "script>\n" + "<script src=\"jq/jquery-ui.min.js\" type=\"text/javascript\"></" + "script>\n" + "<script src=\"jq/datepicker.js\" type=\"text/javascript\"></" + "script>\n" + "</head>\n" + "<body>\n" + "<div id=\"text\" style=\"font: bold 10pt Tahoma\">Enter Approval Date:</div>\n" + "<div id=\"datepicker\"></div>\n" + "</body>\n" + "</html>" var j = window.open("","CALENDAR","width=200,height=250,status=no,resizable=yes,top=200,left=200") j.opener = self; j.document.write(str_html); } </script> </head> <body> <input onclick="open_cal()" type="button" value="Open" name="B1"> </body> </html> Datepicker.js: Code: $(function() { $( "#datepicker" ).datepicker({ dateFormat: 'dd/mm/yy', onSelect: function(dateText, inst) { alert(dateText) window.close() } }) }); Any help with this is greatly and mostly appreciated. Thanks in advance, Cheers, J Hi, I need to add days to a date in javascript, My requirement is as follows: Date is coming from a textbox. eg:- 26/07/2010 days from this statement var day1=document.getElementById('<%=HiddenDate.ClientID %>').value; an eg:- if the date is 28/01/2012 and days Needed to be added=5 the added date should be 02/02/2012. Can anybody help me? Thanks Jamuna Using Adobe Form Javascript validation, how would I do this code for Visual Basic in Javascript (non web) Code: If PurchaseDate.Value > Date Then MsgBox ("PurchaseDate cannot be greater than Today's Date!") Cancel = True End If Something along these lines but this isnt working: Code: If (PurchaseDate.Value > Date) Then { app.alert ("Purchase Date cannot be greater than Today's Date!"); } Thanks hello there this is in vb script. but i dont where to post it. can any one hlep me out plzz I need to check if the date entered by user is within 5th date from current date. I am trying to do it this way entered date has month and date value Code: sResvDate = 01/24 Set sMaxDays to getdate(5) but get date will give year too. and how do i compare if it less than 5th day or not. Hi folks, i am trying to generate a dynamic datefield with date mask "mm/dd/yyyy" and trying to insert it into Oracle db ...i still got the error ORA invalid month ehich means the date filed is not recognized as date: below is what i am doing : newStartDate = document.createElement( 'INPUT' ); newStartDate.setAttribute('type','Date'); newStartDate.setAttribute('id1','id'+ elementid+elementrow); newStartDate.setAttribute('name','StartDateName'+ elementid+elementrow); newStartDate.size=8; newStartDate.style.backgroundColor= bgc; any help thanks ?? Also i want to add a datepicke to this textbox..how it is posible / other option is to use Jquery datepicker but could not know how to impement it thanks again Hi and hope someone can help, I'm reading a book on Javascript and I've been doing their tutorial on getting and setting cookies. Trouble is my code, and their supplied sample, don't work. It is supposed to display a very simple page with an image. When you click the image it is supposed to open up a new (very simple) page. Your help resolving this is greatly appreciated. My thanks, R Code follows... Code: <html> <head> <title>main page</title> <script language=JavaScript> var lastUpdated = new Date("Tue, 28 Dec 2010"); function getCookieValue(cookieName) { var cookieValue = document.cookie; var cookieStartsAt = cookieValue.indexOf(" " + cookieName + "="); if (cookieStartsAt == -1) { cookieStartsAt = cookieValue.indexOf(cookieName + "="); } if (cookieStartsAt == -1) { cookieValue = null; } else { cookieStartsAt = cookieValue.indexOf("=", cookieStartsAt) + 1; var cookieEndsAt = cookieValue.indexOf(";", cookieStartsAt); if (cookieEndsAt == -1) { cookieEndsAt = cookieValue.length; } cookieValue = unescape(cookieValue.substring(cookieStartsAt,cookieEndsAt)); } return cookieValue; } function setCookie(cookieName, cookieValue, cookiePath, cookieExpires) { cookieValue = escape(cookieValue); if (cookieExpires == "") { var nowDate = new Date(); nowDate.setMonth(nowDate.getMonth() + 6); cookieExpires = nowDate.toGMTString(); } if (cookiePath != "") { cookiePath = ";Path=" + cookiePath; } document.cookie = cookieName + "=" + cookieValue + ";expires=" + cookieExpires + cookiePath; } </script> </head> <body> <h2 align=center> Welcome to my website </h2> <br><br> <center> <script> var lastVisit = getCookieValue("Last Visit"); if (lastVisit != null) { lastVisit = new Date(lastVisit); if (lastVisit < lastUpdated) { document.write("<a href=\"WhatsNew.htm\">"); document.write("<img src=\"new.jpg\" border=0></a>"); } } var nowDate = new Date(); setCookie("LastVisit", nowDate.toGMTString(),"","") </script> </center> </body> </html> Hello, I need your help. I have the following drop-down box as an example: [== FRUITS ==] apples oranges pairs kiwi lemon How can I use the code below to set the value of the drop down without knowing its value number (3)? document.getElementById('BOX1').value = 'pairs' Much thanks and appreciation for everyones help. Cheers, J I cannot get the cookie to save, I'm pretty new at web designing in general. If you could, the name of the cookie be cirulcook, also any advice you would have for me would be great! Code: <script><!-- function SETcookie(){ document.cookie="Selected="+document.getElementById('myList').selectedIndex; } function GETcookie(){ if (document.cookie){ eval(document.cookie); document.getElementById('myList').selectedIndex=Selected; }}// --></script> </head> <body onLoad="GETcookie()"> <select id="myList" onChange="SETcookie()"> <option value="1">Option 1</option> <option value="2">Option 2</option> <option value="3">Option 3</option> <option value="4">Option 4</option> </select> Hi and hope someone can help. I'm setting up a fictitious shopping page which uses cookies to remember what a user has selected. The products are photographs that the user can select either framed or unframed versions and I'm trying to put a confirmation box if the user actually requests framed and unframed versions of the same photograph. The code I'm using actually worked before I tried to add this extra functionality but I can't work out how to test for this extra bit. Here's my code and it sets cookies with names as either lulworth01 for the unframed version or lulworth01f for the framed version. The bits that work are in black and my extra code for this test is in red. Any help would be appreciated. Thanks Rog Code: function getCookie(name) { var index = cart.indexOf(name + "="); if(index == -1) return null; index = cart.indexOf("=", index) +1; var endstr = cart.indexOf(";",index); if (endstr == -1) endstr = cart.length; return unescape(cart.substring(index, endstr)); } function setCookie(name) { if ((name.charAt(name.length-1)='f') && (getCookie(name.substring(0,10))!=null)) { confirm("You seem to have placed orders for both a mounted and framed image of the same photograph.\n\nIs that OK?"); } else { alert("Thank you.\n\nYour basket has been updated."); x=parseInt(getCookie(name)) || 0; y=x+1; var today = new Date(); var expiry = new Date(today.getTime()+28*24*60*60*1000); // plus 28 days document.cookie=name+"="+y+";expires="+expiry.toGMTString(); cart = document.cookie; } } Hello, I'm using pull downs for date but it always starts up "Dec" "31" "Year". How can I set it to start as "Month" "Date" "Year"? Thanks. PHP Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Main</title> </head> <body> <br> <form name="form1" id="startOfForm"> <table><tbody> <tr> <td class="question"><label for="birthdate">Select Birthdate</label></td> <td> <select name="selMonth" id="selMonth" > <option value=0 selected>Month</option> <option selected value="1">Jan</option> <option selected value="2">Feb</option> <option selected value="3">Mar</option> <option selected value="4">Apr</option> <option selected value="5">May</option> <option selected value="6">Jun</option> <option selected value="7">Jul</option> <option selected value="8">Aug</option> <option selected value="9">Sept</option> <option selected value="10">Oct</option> <option selected value="11">Nov</option> <option selected value="12">Dec</option> </select> <select name="selDate" id="selDate" > <option value=0 selected>Date</option> <option selected value="1">1</option> <option selected value="2">2</option> <option selected value="3">3</option> <option selected value="4">4</option> <option selected value="5">5</option> <option selected value="6">6</option> <option selected value="7">7</option> <option selected value="8">8</option> <option selected value="9">9</option> <option selected value="10">10</option> <option selected value="11">11</option> <option selected value="12">12</option> <option selected value="13">13</option> <option selected value="14">14</option> <option selected value="15">15</option> <option selected value="16">16</option> <option selected value="17">17</option> <option selected value="18">18</option> <option selected value="19">19</option> <option selected value="20">20</option> <option selected value="21">21</option> <option selected value="22">22</option> <option selected value="23">23</option> <option selected value="24">24</option> <option selected value="25">25</option> <option selected value="26">26</option> <option selected value="27">27</option> <option selected value="28">28</option> <option selected value="29">29</option> <option selected value="30">30</option> <option selected value="31">31</option> </select> <select name="selYear" id="selYear" > <option value=0 selected>Year</option> <option value="2001">2001</option> <option value="2000">2000</option> <option value="1999">1999</option> <option value="1998">1998</option> <option value="1997">1997</option> <option value="1996">1996</option> <option value="1995">1995</option> <option value="1994">1994</option> <option value="1993">1993</option> <option value="1992">1992</option> <option value="1991">1991</option> <option value="1990">1990</option> <option value="1989">1989</option> </select> </td> </tr> <tr> <td colspan=2><input type="submit" value="Submit form"></td> </tr> </tbody></table> </form> </body> </html> What I'm trying to do is to do something similar to what this person wanted on their question: http://www.webmasterworld.com/javascript/3338586.htm I already have it so when the user clicks on one of the links, then it changes to the active class. But now I would like to have the first link already have the active class (which is the effect the links will have when the user clicks on it) and then have the same effect happen thereafter the user clicks on the links. Here is the Javascript: Code: <script type="text/javascript"> var hrefs=document.getElementsByTagName("a"); var hrefs=document.getElementsByClassName("links"); var preA=""; for(var i=0;i<hrefs.length;i++){ hrefs[i].onclick=function(){ if(preA!="" && preA!=this){ preA.className="links"; } this.className="active"; preA=this; } } </script> Here is the CSS: Code: a.links:link { color: #FFF; text-decoration: none; } a.links:hover { color: #96C; text-decoration: none; } a.active { color: #96C; text-decoration: none; } Here is the HTML: Code: <a class="links" href="#">Curriculum Vitae</a> | <a class="links" href="#">Teaching Philosophy</a> | <a class="links" href="#">Artist Statement</a> I am sorry the following code is a bit of a mouthful, but I can't find a better way to display the problem. The code works as expected in Chrome, but not in IE and FF. In IE the error is "Object doesn't support this action" and in FF "setting a property that has only a getter". In Chrome there is no error in the console. There are three javascript <script>...</script>s that exist to display a <td> row in a table with a particular graphic depending on the screen width. The odd thing is that in both IE and FF (and of course Chrome), the first two scripts display perfectly well. Why does the third <script> produce an error? It has exactly the same form as the two before it. I can only guess it has something to do with where it occurs Googling the FF error, it has something to do with trying to set a read-only property, but then why do the first two <scripts> work? They are no different (at least I can't see a difference.) Code: <table border="0" width="100%" cellpadding="0" style="border-collapse: collapse" id="table3768"> <script> if (screen.width > 1280) { document.write("<td valign=\"top\" background=\"..\/..\/img\/lesson2.gif\" width=\"840\" height=\"301\">"); } else { document.write("<td valign=\"top\" background=\"..\/..\/img\/lesson.gif\" width=\"369\" height=\"301\">"); } </script> <p> </p> <div align="left"> </table> <table border="0" style="border-collapse: collapse" cellpadding="15"> <tr> <td width="40"> </td> <script> if (screen.width > 1280) { document.write("<td width=\"300\">"); } else { document.write("<td width=\"165\">"); } </script> <font face="Trebuchet MS" color="#808000">Today's lesson is about setting goals...</font></td> </tr> </table> </div> </td> <td rowspan="3"> <table border="0" cellspacing="0" style="border-collapse: collapse" cellpadding="0" id="table3920"> <tr> <td><img border="0" src="../../img/teltopw.jpg" width="550" height="9"></td> </tr> <tr> <td background="../../img/telbarw.jpg"> <p align="center"> <iframe name="ITV" src="lesson1TV.html" marginwidth="0" marginheight="0" scrolling="no" border="0" frameborder="0" width="480" height="376"> Your browser does not support inline frames or is currently configured not to display inline frames. </iframe></p> </td> </tr> <tr> <td><img border="0" src="../../img/telbotw.jpg" width="550" height="11"></td> </tr> </table> </td> <td align="center"> <a rel="nofollow" target="_blank" href="http://www.apple.com/quicktime/download/"> <img border="0" src="../../img/quicktimeani.gif" width="129" height="184"></a></td> </tr> <tr> <script> if ((screen.width = 1440) || (screen.width = 1400)) { document.writeln("<td valign=\"top\" width=\"100%\" background=\"\/images\/101online\/listening\/lesson16\/notebot2.gif\" width=\"450\" height=\"50\">"); } else if (screen.width <= 1280) { document.writeln("<td valign=\"top\" width=\"100%\" background=\"\/images\/101online\/listening\/lesson16\/notebot.gif\" width=\"294\" height=\"50\">");; } </script> </td> <td valign="bottom"> </td> </tr> <tr> <td valign="bottom" width="100%"> <div align="right"> <table border="0" cellpadding="5" style="border-collapse: collapse" id="table3926"> <tr> <td align="center"> <a onmousedown="soundManager.play('piano','../../media/mp3/piano.mp3'); return true;" href="javascript: goFull('FULLSCREEN/lesson1full.html','info','width=1020,height=760,left=0,top=0,toolbar=no,scrollbars=no,status=no,directories=no,menubar=no,location=no,resizable=no');"> <img src="../../img/poster1ani.gif" border="0" width="95" height="29"></a> <b><font size="1" face="Arial" color="#000080"> ON DISK</font></b></td> <td align="center"><b><font size="1" face="Arial" color="#000080">OR </font></b> <a onmousedown="soundManager.play('piano','../../media/mp3/piano.mp3'); return true;" href="javascript: goFull('CDRIVE/lesson1Cfull.html','info','width=1020,height=760,left=0,top=0,toolbar=no,scrollbars=no,status=no,directories=no,menubar=no,location=no,resizable=no');"><img src="../../img/poster7.bmp" border="0" width="53" height="30"></a> <b><font size="1" face="Arial" color="#000080"> DRIVE</font></b></td> </tr> </table> </div> </td> <td valign="bottom"> <iframe name="sounds" src="../../pagesounds.html" width="160" height="66" marginwidth="1" marginheight="1" scrolling="no" border="0" frameborder="0"> Your browser does not support inline frames or is currently configured not to display inline frames. </iframe></td> </tr> </table> Any light on this would be most welcome! Alright well Hello, I currently have a table that shows a background image and I have 1 TD with 100% width and height and in that TD I have a DIV that moves by margin-left and margin-top via JavaScript and the height is approx 20px by 20px, so basically I have a map with a character that moves when keys are pressed. My problem is I'm having trouble setting limits (where the character cannot go inside the TD). etc if it reachs a X and Y then it would stop, but it's not that easy, I currently have this in a IF function when the keys are pressed: Code: var x; var y; var exclude = { x: [50, 50, 50, 50, 50], y: [50, 60, 70, 80, 90] }; if (exclude.x.indexOf(x) !== -1 && exclude.y.indexOf(y) !== -1){ // dismiss } else { //run main code.. } But that code doesn' work correctly because I want the numbers in exclude.x to match the oppisite of exclude.y so 50 and 50, 50 and 60 but instead its like this 50 and 50 or 60 or 70 or 80 or 90. I just want it to be set so it matches the number... Code: x: [1, 2, 3, 4, 5], y: [1, 2, 3, 4, 5] Hope you can help I've been having trouble for awhile now, thanks. Greetings and salutations. My text and what I have been researching on the internet has not been very helpful in determining the code that I need to prevent a user from entering his/her information more than once. Here is my current code Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD.HTML 4.01 Transitional//EN" "http://www.w3.org/TR/htm14/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Kudler Fine Foods Contact Page</title> <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1"> <!---Kami Demnyan 21 December 2009--> <script type="text/javascript"> /*<![CDATA[*/ <!--This code ensures that the zip code and telephone numbers are actual numerical digits, not letters--> function checkForNumber(fieldValue) { var numberCheck = isNaN(fieldValue); if (numberCheck == true) { window.alert ("Please enter a numerical value"); return false; } } <!--This code ensures that all of the fields contain text and I have it functioning now--> function submitForm() { if (document.forms[0].name.value == "" || document.forms[0].address.value == "" || document.forms[0].city.value == "" || document.forms[0].state.value == "" || document.forms[0].zip.value == "" || document.forms[0].phone.value == "" || document.forms[0].email.value == "") { window.alert("Please enter your missing information"); return false; } else return true; } function getCookie(NameOfCookie) { if (document.cookie.length > 0) { begin = document.cookie.indexOf(NameOfCookie+"="); if (begin != -1) { begin += NameOfCookie.length+1; end = document.cookie.indexOf(";", begin); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(begin, end)); } } return null; } function setCookie(NameOfCookie, value, expiredays) { var ExpireDate = new Date (); ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000)); document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()); } function delCookie (NameOfCookie){ if (getCookie(NameOfCookie)) { document.cookie = NameOfCookie + "=" +"; expires=Tues, 02-Feb-10 00:00:01 GMT"; } } /*]]>*/ </script> </head> <body> <h1> KUDLER FINE FOODS </h1> <h2> JOIN OUR MAILING LIST</h2> <!--This is where the user will input all of their information to join the mailing list--> <form action="completeform.html" method="get" onsubmit="return submitForm();" enctype="application/x-www-form-urlencoded"> <p>Name<br /> <input type="text" name="name" size="50" /></p> <p>Address<br /> <input type="text" name="address" size="50" /></p> <p>City, State, Zip <br /> <input type="text" name="city" size="30" /> <input type="text" name="state" size="3" /> <input type="text" name="zip" size="10"; onchange="return checkForNumber(this.value)"; /></p> <p>Telephone<br /> <input type="text" name="phone" size="25" onchange="return checkForNumber(this.value)"; /></p> <p>Email Address<br /> <input type="text" name="email" size="50" /></p> <!--This is where the submit and reset buttons are located--> <p><input type="submit" value="Submit Form" /> <p><input type="reset" value="Reset Form" /> </form> </body> </html> I have created a new web page to link the duplicate cookie too, titled doubleinfo.html. This is what I am using to let the user know that their information has already been entered. My text is telling me that I need to look for a nextform() function, but I didn't have to write one so what would I need to do, if anything, to start the document.cookie = "name" codes? Any help would be greatly appreciated, thanks in advance. |