JavaScript - A Getjson Referrer Question
A little question:
Which referrer gets facebook if I make a getjson to https://graph.facebook.com/someid?callback=? Does facebook get as http referrer the client or my server? Similar TutorialsI have used this script successfully: http://www.javascriptkit.com/script/...2/refer2.shtml However, is there a way to block the following work-around (example only): http://www.their-url.com/redir.php?u...ww.my-url.com/ The redir.php makes it possible to get past the script. Here's my code Code: (function() { var GOOGLE_PLUS_SCRIPT_URL = 'https://apis.google.com/js/client:plusone.js'; var CHANNELS_SERVICE_URL = 'https://www.googleapis.com/youtube/v3/channels'; var VIDEOS_UPLOAD_SERVICE_URL = 'https://www.googleapis.com/upload/youtube/v3/videos?uploadType=resumable&part=snippet'; var VIDEOS_SERVICE_URL = 'https://www.googleapis.com/youtube/v3/videos'; var INITIAL_STATUS_POLLING_INTERVAL_MS = 15 * 1000; var accessToken; $.getJSON( "the_key.txt", function( data ) { accessToken = data.access_token; function initiateUpload(e) { e.preventDefault(); var file = $('#file').get(0).files[0]; if (file) { $('#submit').attr('disabled', true); var gettags = $('#tags').val() var metadata = { snippet: { title: $('#title').val(), description: $('#description').val(), categoryId: 20, tags: ['"' + gettags.replace(/,/g , '", "') + '"'] }, }; $.ajax({ url: VIDEOS_UPLOAD_SERVICE_URL, method: 'POST', contentType: 'application/json', headers: { Authorization: 'Bearer ' + accessToken, 'x-upload-content-length': file.size, 'x-upload-content-type': file.type }, data: JSON.stringify(metadata) }).done(function(data, textStatus, jqXHR) { resumableUpload({ url: jqXHR.getResponseHeader('Location'), file: file, start: 0 }); }); } } function resumableUpload(options) { var ajax = $.ajax({ url: options.url, method: 'PUT', contentType: options.file.type, headers: { 'Content-Range': 'bytes ' + options.start + '-' + (options.file.size - 1) + '/' + options.file.size }, xhr: function() { // Thanks to http://stackoverflow.com/a/8758614/385997 var xhr = $.ajaxSettings.xhr(); if (xhr.upload) { xhr.upload.addEventListener( 'progress', function(e) { if(e.lengthComputable) { var bytesTransferred = e.loaded; var totalBytes = e.total; var percentage = Math.round(100 * bytesTransferred / totalBytes); $('#upload-progress').attr({ value: bytesTransferred, max: totalBytes }); $('#percent-transferred').text(percentage); $('#bytes-transferred').text(bytesTransferred); $('#total-bytes').text(totalBytes); $('.during-upload').show(); } }, false ); } return xhr; }, processData: false, data: options.file }); ajax.done(function(response) { var videoId = response.id; document.location="http://ez-gaming.net/index.php?app=videos&module=post§ion=submit&do=add_video&cat=&vidid=" + videoId; }); ajax.fail(function() { $('#submit').click(function() { alert('Not yet implemented!'); }); $('#submit').val('Resume Upload'); $('#submit').attr('disabled', false); }); } $(function() { $.getScript(GOOGLE_PLUS_SCRIPT_URL); $('#upload-form').submit(initiateUpload); }); }); })(); As you see I get JSON from the_key.txt and assign in to a variable. I call this variable later in the script but it doesn't seem to work. I did Code: alert(accessToken); after I put Code: $.getJSON( "the_key.txt", function( data ) { accessToken = data.access_token; and it worked and gave the correct string. But when I call accessToken in the initiateUpload function it does not work. AS shown he Code: function initiateUpload(e) { e.preventDefault(); var file = $('#file').get(0).files[0]; if (file) { $('#submit').attr('disabled', true); var gettags = $('#tags').val() var metadata = { snippet: { title: $('#title').val(), description: $('#description').val(), categoryId: 20, tags: ['"' + gettags.replace(/,/g , '", "') + '"'] }, }; $.ajax({ url: VIDEOS_UPLOAD_SERVICE_URL, method: 'POST', contentType: 'application/json', headers: { Authorization: 'Bearer ' + accessToken, 'x-upload-content-length': file.size, 'x-upload-content-type': file.type }, data: JSON.stringify(metadata) }).done(function(data, textStatus, jqXHR) { resumableUpload({ url: jqXHR.getResponseHeader('Location'), file: file, start: 0 }); }); } } Any ideas how to solve this? Any help would be awesome and much appreciated! I'm trying to change an id by referencing the previous site the user was on. In this case the user will be coming from either facebook or linkedin. I'm not sure if i'm calling the referrer property correctly. Again, any help is greatly appreciated! <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script language="JavaScript"> if(document.referrer.toLowerCase().indexOf("facebook") != -1) { document.getElementById("phone").innerHTML = "555.555.5555"; } else if (document.referrer.toLowerCase().indexOf("linkedin") != -1) { document.getElementById("phone").innerHTML = "222.222.2222"; } else { //Default code } </script> </head> <body> <p id="phone">123.456.7890</p> </body> Hi all, I have a frame structure (three frames) where the top one is my flash navigation. The navigation itself is quite complex so I have given up on the idea of creating a back button code to control the flash. All I want to do now is to refresh the flash page when browser's back button is pressed. What I would like to do is to set a variable of the previous page I just have been so when I hit browser's back button I know if this page is the same as the variable. In each individual page i would set the varaible to be the previous page. Here are few things I have tried so far and none of them seems to work (even online!) (sections is the name of the main frame) old_page = parent.sections.history.previous; old_page =document.referrer; I tried both of them at the beginning of each page. then used onUnload command in the body tag to call a function on another frame where I have the comparison: function check_history(old_page){ if (old_page == parent.sections.location){ alert(" refresh flash"); } If I use referrer, the value is null (empty) or if I use history the variable is undefined. Has anyone come accross with anything similar? Thank you very much for your help. this is prob more simple than im thinking but i cant grasp it at the moment.. on the process page for my site, it has a link to view the account i click on that link and then i can click the back link to go back.. when i do, i get a page has expired message the reason is because the original link there is Code: http://www.xxx.com?ms=1 and that ms1 no longer exists after i leave the page because i unset it. once i leave that page so im curious is there a way to have the main url Code: http://www.xxx.com as the referrer when i click on the link so that when i use the back link Code: <a href="javascript: void(0)" onClick="javascript:history.go(-1)">Go Back</a> it can go back to that main page url instead of tring to find the one with ms1 on it.. i just realized i should have posted this is javascript sorry im tired lol Hello, I have very little knowledge of javascript, other than modifying existing scripts, and I can't find anything about this particular problem. I need some help on creating a simple script that will display a div ONLY if the user comes from a certain page within the same site. Not sure if that was clear, but let me try with specifics. There is a link to a page called 'Clients' on the 'About Us' page. If a user goes directly to 'Clients', they should have a normal experience. If, however, they come via the 'About Us' page, I want to display a div at the bottom of the page that will take them back to the 'About Us' page. I know how to get a referrer, and I know how to show/hide divs. I just don't know how to combine the two. Can anyone help? I was asked to redo a menu for this site: http://www.listlabs.com/index.php It was originally an imaged based menu, but they wanted it all changed to css/html. I used quickmenu and it used JS to produce the arrows at the top of each menu item. Now to my question... I'm trying to program the menu items to stay active when on the current page. At first, it looks correct, but if you hover back over the menu, it changes back to the inactive state. Any help would be great! Thanks. Ok i have been working on this for a while now. I have to have 3 fish swim across the screen in both direction. I have tried a few things but nothing is working. Can someone please explain to me what I am doing wrong. here is my code for you guys to look at it. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Fish tank</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript"> // <![CDATA[ var fishPos = new Array(3); fishPos[0] = "fish1.gif"; fishPos[1] = "fish2.gif"; fishPos[2] = "fish3.gif"; var fillPosition = 10; for(var i = 0; i < 50; ++i) { horizontal[i] = fillPosition; fillPosition += 10; } function fishSwim(fishNumber) { document.getElementById("fishPos").style.left = horizontal + "px"; ++fishPos[fishNumber]; if (fishPos[fishNumber] == 49) fishPos[fishNumber] = 0; } function startSwimming() { setInterval(fish1Swim, 100); } // ]]> </script> </head> <body onload="startSwimming();"> <p><span id="fish1" style= "position:absolute; left:10px; top:10px"><img src="fish1.gif" alt="Image of a fish" /></span></p> <p><span id="fish2" style= "position:absolute; left:10px; top:120px"><img src="fish3.gif" alt="Image of a fish" /></span></p> <p><span id="fish3" style= "position:absolute; left:10px; top:250px"><img src="fish2.gif" alt="Image of a fish" /></span></p> </body> </html> I am really not understanding and in my book it only give me a page to read about the animation. I am still new to it. Thanks for looking Could someone please take a look at my code? It's a simple quiz with one multiple choice question and one fill in the blank. When the user clicks on 'submit' I tried to show some kind of response with correct/incorrect images next to the question. It works with the multiple choice question, but not with the fill in the blank. How can I get the fill in the blank question to work. It always shows the answer as being wrong. Thank you. Quote: answer_list = [ ['False'], ['body','hips','knees'] // Note: No comma after final entry ]; response = []; function setAnswer(question, answer) { response[question] = answer; } function CheckAnswers() { var correct = 0; var flag, resp, answ; for (var i = 0; i < answer_list.length; i++) { flag = false; for(var j=0; j<answer_list[i].length; j++){ resp = response[i].toLowerCase(); answ = answer_list[i][j].toLowerCase(); ################################################################################################# if (response[0] == answer_list[0]) { flag = true; document.myquiz.a1c.style.backgroundImage="url('correct.gif')"; } else{ document.myquiz.a1c.style.backgroundImage = "url('incorrect.gif')"; document.myquiz.a1c.value = " ANS: False. Position the head snugly against the top bar of the frame and then bring the foot board to the infant's feet."; } if (response[1] == answer_list[1]) { flag = true; document.myquiz.a1d.style.backgroundImage="url('correct.gif')"; } else{ document.myquiz.a1d.style.backgroundImage = "url('incorrect.gif')"; } ################################################################################################### } if (flag) { correct++; } } document.writeln("You got " + correct + " of " + answer_list.length + " questions correct!"); } </SCRIPT> </HEAD> <FORM name="myquiz"> <B>1. When measuring height/length of a child who cannot securely stand, place the infant such that his or her feet are flat against the foot board.</B> <label><INPUT TYPE=radio NAME=question0 VALUE="True" onClick="setAnswer(0,this.value)">True</label> <label><INPUT TYPE=radio NAME=question0 VALUE="False" onClick="setAnswer(0,this.value)">False</label> <textarea rows="2" cols="85" name="a1c" style="background-repeat:no-repeat"></textarea> <B>2. When taking a supine length measurement, straighten the infant's <INPUT id="test" TYPE=text NAME=question1 size=10 onChange="setAnswer(1, this.value)">, <INPUT id="test" TYPE=text NAME=question1 size=10 onChange="setAnswer(1, this.value)">, and <INPUT id="test" TYPE=text NAME=question1 size=10 onChange="setAnswer(1, this.value)">.</B> <textarea rows="2" cols="85" name="a1d" style="background-repeat:no-repeat"></textarea> <INPUT TYPE="button" NAME="check" VALUE="Check Answers" onClick=CheckAnswers()> </FORM> </div> </FONT> </BODY> </HTML> Hi all I am doing an assigment and have gotten to the end and cannot get the unordered list to work. If I try having my </script> tag below the </ul> it does not display anything If i have it above it will only display the varible names or what ever I type between the <li> </li> tag and not the varible assigment. num1,2,3,4 being the varible name. ie. </script> <ul> <li>num1</li> I have tryed <li>+num2+</li> also tryed <li>(num3)</li> also tryed <li>'num4'</li> also tryed and does not display </ul> </head> </html> The following does not display any thing <ul> <li>num1</li> I have tryed <li>+num2+</li> also tryed <li>(num3)</li> also tryed <li>'num4'</li> also tryed </ul> </script> </head> </html> I need to get the <li></li> to display not what I type in there but the assigment of the varible name I put in there.,or the output the varible calculation produces. Hope that was easy to understand lol Any advise would be awesome, cheers Shayne Darcy. hello all ive been asked to create a javascript slideshow.... and i don't really understand it that much i know a little javscript but not much........ is thier any helpful sites that i can use to teach you step by step to make a javascript slide show???? also if don't want loads of code to be used, i want the code to be clean insted of loads and loads of code what is just unessary. i will be linking the javascript file to the html file so i need to keep the code to a min LOL CHEERS Hello, i haven't understood how to find the id from buttons, links, button images to auto click yet for example, i want to CLICK HERE how can i do that? how i find the id (I Own firefox with firebug and know basic html) it will be something like javascript:document.GetElementById('id').click(); right? but just want to know how to find or create ids on sites for auto click thanks I'm not sure if this is the correct forum or not, but here goes. I want to make a very simple XUL document. Just a simple basic window to be opened up, but, i want the XUL to Load and Render an HTML File. I'm not sure about what function(s) to call to achieve this, can anyone give me any ideas to go on? here's what i have so far use my JavaScript Function called LoadFromDisk(FileName), if the file is there or the load is sucessfull, it can be stored as a variable. And then i have a single Division in the XUL document called RenderWindow. From there i set the innerHTML of the RenderWindow to the data that was loaded from the disk. Is this the right way? thanks You are given a mathematical expression containing integers and the basic operations: *,+,-, /. Find the number of unique results that can be obtained by parenthesizing the expression differently. i.e., by changing the order of evaluation of the operations. Note that all operations are integer operations. For example, if the input is 2 ∗ 3 + 6/2, your output should be 4. Plzz help me with this qs......... I'm in a computer coding class, and I'm having a bit of trouble with Javascript. I'm not looking for anyone to do my homework for me, but any hints you could give me as to why this code isn't working would be greatly appreciated. Basically, I need an empty text box where the user enters their guess as to my age. The user enters their guess, and then gets an answer as to whether their guess is right, too high, or too low. The page looks right, but I can't get the function to work. Thank you... <html> <head> <script> function howoldami(age) if(age=23) { alert("You guessed right!"); } else if { (age>23) alert("I'm not that old."); } else { alert("I'm not that young."); } </script> </head> <body> <form> Guess My Age!<input name="age"><br> <input type=button value=Guess! onclick="howoldami(age.value)"> </form> </body> </html> Hello, I'm still really new to Javascript and need the help of an expert. I found the following script, for a date picker, however, how can it be modified such that the date selected is output into the date format of dd/mm/yyyy, I also don't need the time, so how could I get the chosen date into that format and ignore the time? Code: // Title: Timestamp picker // Description: See the demo at url // URL: http://us.geocities.com/tspicker/ // Script featured on: http://javascriptkit.com/script/script2/timestamp.shtml // Version: 1.0 // Date: 12-05-2001 (mm-dd-yyyy) // Author: Denis Gritcyuk <denis@softcomplex.com>; <tspicker@yahoo.com> // Notes: Permission given to use this script in any kind of applications if // header lines are left unchanged. Feel free to contact the author // for feature requests and/or donations function show_calendar(str_target, str_datetime) { var arr_months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; var week_days = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]; var n_weekstart = 1; // day week starts from (normally 0 or 1) var dt_datetime = (str_datetime == null || str_datetime =="" ? new Date() : str2dt(str_datetime)); var dt_prev_month = new Date(dt_datetime); dt_prev_month.setMonth(dt_datetime.getMonth()-1); var dt_next_month = new Date(dt_datetime); dt_next_month.setMonth(dt_datetime.getMonth()+1); var dt_firstday = new Date(dt_datetime); dt_firstday.setDate(1); dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7); var dt_lastday = new Date(dt_next_month); dt_lastday.setDate(0); // html generation (feel free to tune it for your particular application) // print calendar header var str_buffer = new String ( "<html>\n"+ "<head>\n"+ " <title>Calendar</title>\n"+ "</head>\n"+ "<body bgcolor=\"White\">\n"+ "<table class=\"clsOTable\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"+ "<tr><td bgcolor=\"#4682B4\">\n"+ "<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+ "<tr>\n <td bgcolor=\"#4682B4\"><a href=\"javascript:window.opener.show_calendar('"+ str_target+"', '"+ dt2dtstr(dt_prev_month)+"'+document.cal.time.value);\">"+ "<img src=\"prev.gif\" width=\"16\" height=\"16\" border=\"0\""+ " alt=\"previous month\"></a></td>\n"+ " <td bgcolor=\"#4682B4\" colspan=\"5\">"+ "<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">" +arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</font></td>\n"+ " <td bgcolor=\"#4682B4\" align=\"right\"><a href=\"javascript:window.opener.show_calendar('" +str_target+"', '"+dt2dtstr(dt_next_month)+"'+document.cal.time.value);\">"+ "<img src=\"next.gif\" width=\"16\" height=\"16\" border=\"0\""+ " alt=\"next month\"></a></td>\n</tr>\n" ); var dt_current_day = new Date(dt_firstday); // print weekdays titles str_buffer += "<tr>\n"; for (var n=0; n<7; n++) str_buffer += " <td bgcolor=\"#87CEFA\">"+ "<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"+ week_days[(n_weekstart+n)%7]+"</font></td>\n"; // print calendar table str_buffer += "</tr>\n"; while (dt_current_day.getMonth() == dt_datetime.getMonth() || dt_current_day.getMonth() == dt_firstday.getMonth()) { // print row heder str_buffer += "<tr>\n"; for (var n_current_wday=0; n_current_wday<7; n_current_wday++) { if (dt_current_day.getDate() == dt_datetime.getDate() && dt_current_day.getMonth() == dt_datetime.getMonth()) // print current date str_buffer += " <td bgcolor=\"#FFB6C1\" align=\"right\">"; else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6) // weekend days str_buffer += " <td bgcolor=\"#DBEAF5\" align=\"right\">"; else // print working days of current month str_buffer += " <td bgcolor=\"white\" align=\"right\">"; if (dt_current_day.getMonth() == dt_datetime.getMonth()) // print days of current month str_buffer += "<a href=\"javascript:window.opener."+str_target+ ".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+ "<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">"; else // print days of other months str_buffer += "<a href=\"javascript:window.opener."+str_target+ ".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+ "<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">"; str_buffer += dt_current_day.getDate()+"</font></a></td>\n"; dt_current_day.setDate(dt_current_day.getDate()+1); } // print row footer str_buffer += "</tr>\n"; } // print calendar footer str_buffer += "<form name=\"cal\">\n<tr><td colspan=\"7\" bgcolor=\"#87CEFA\">"+ "<font color=\"White\" face=\"tahoma, verdana\" size=\"2\">"+ "Time: <input type=\"text\" name=\"time\" value=\""+dt2tmstr(dt_datetime)+ "\" size=\"8\" maxlength=\"8\"></font></td></tr>\n</form>\n" + "</table>\n" + "</tr>\n</td>\n</table>\n" + "</body>\n" + "</html>\n"; var vWinCal = window.open("", "Calendar", "width=200,height=250,status=no,resizable=yes,top=200,left=200"); vWinCal.opener = self; var calc_doc = vWinCal.document; calc_doc.write (str_buffer); calc_doc.close(); } // datetime parsing and formatting routimes. modify them if you wish other datetime format function str2dt (str_datetime) { var re_date = /^(\d+)\-(\d+)\-(\d+)\s+(\d+)\:(\d+)\:(\d+)$/; if (!re_date.exec(str_datetime)) return alert("Invalid Datetime format: "+ str_datetime); return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6)); } function dt2dtstr (dt_datetime) { return (new String ( dt_datetime.getDate()+"-"+(dt_datetime.getMonth()+1)+"-"+dt_datetime.getFullYear()+" ")); } function dt2tmstr (dt_datetime) { return (new String ( dt_datetime.getHours()+":"+dt_datetime.getMinutes()+":"+dt_datetime.getSeconds())); } Thanks for everyones help. Cheers, J This is what I am aiming for. I want to be able to click on a word that would then write text in a specified area. This is what I came up with but it writes it at the top of the page and only for a moment then disappears.... These are my clickable words Code: <a href="#textarea" onClick="MathHomework('W2')">Week 2</a> <a href="#textarea" onClick="MathHomework('W3')">Week 3</a> the anchor named 'textarea' is where I want the output to be written which is placed on my html page. This is my newbie script Code: <script type="text/javascript"> function MathHomework(week) { if (week == "W2") document.write("<p>Review Chapter Twelve</p>"); else if (week == "W3") document.write("<p>Final Chapter Review Test</p>"); } </script> <a name="textarea"> (text area for javascript output)</a> so is my onclick syntax wrong maybe? and yes I have read rule#5 and I am trying to understand my mistakes. Thank you in advance I'm using the following javascript for my main navigation. Quote: var mastertabvar=new Object() mastertabvar.baseopacity=0 mastertabvar.browserdetect="" function showsubmenu(masterid, id){ if (typeof highlighting!="undefined") clearInterval(highlighting) submenuobject=document.getElementById(id) mastertabvar.browserdetect=submenuobject.filters? "ie" : typeof submenuobject.style.MozOpacity=="string"? "mozilla" : "" hidesubmenus(mastertabvar[masterid]) submenuobject.style.display="block" instantset(mastertabvar.baseopacity) highlighting=setInterval("gradualfade(submenuobject)",50) } function hidesubmenus(submenuarray){ for (var i=0; i<submenuarray.length; i++) document.getElementById(submenuarray[i]).style.display="none" } function instantset(degree){ if (mastertabvar.browserdetect=="mozilla") submenuobject.style.MozOpacity=degree/0 else if (mastertabvar.browserdetect=="ie") submenuobject.filters.alpha.opacity=degree } function gradualfade(cur2){ if (mastertabvar.browserdetect=="mozilla" && cur2.style.MozOpacity<1) cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99) else if (mastertabvar.browserdetect=="ie" && cur2.filters.alpha.opacity<100) cur2.filters.alpha.opacity+=10 else if (typeof highlighting!="undefined") //fading animation over clearInterval(highlighting) } function initalizetab(tabid){ mastertabvar[tabid]=new Array() var menuitems=document.getElementById(tabid).getElementsByTagName("li") for (var i=0; i<menuitems.length; i++){ if (menuitems[i].getAttribute("rel")){ menuitems[i].setAttribute("rev", tabid) //associate this submenu with main tab mastertabvar[tabid][mastertabvar[tabid].length]=menuitems[i].getAttribute("rel") //store ids of submenus of tab menu if (menuitems[i].className=="selected") showsubmenu(tabid, menuitems[i].getAttribute("rel")) menuitems[i].getElementsByTagName("a")[0].onmouseover=function(){ showsubmenu(this.parentNode.getAttribute("rev"), this.parentNode.getAttribute("rel")) } } } } Can someone please show me how to add an ".onmouseout" function so that when a user rolls out of any of the top level navigation the submenu defaults to the navigation for the current page? http://www.mohrdesigns.com Thanks in advance for any help! I'm adding a text field named city. I'm trying to validate it using MM_validateForm() however I'm not sure how to add it into the javascript. Can anyone help out? Code: <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 the number '+min+'.\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> Code: <input name="submit" type="submit" class="submit-button" onclick="MM_validateForm('name','','R','email','','RisEmail','answer','','RinRange4:4','city','message','','R');return document.MM_returnValue" value="Submit" /> |