JavaScript - Set To Ignore Errors
is there anyway to set my code in javascript to ignore errors
I have an error that comes up on ie but everything workes fine and i can't find the source of the error -- can i tell the browser to ignore it? Similar TutorialsI am trying to read data from excel file and use the same to populate a select menu. If any cells are blank, I want to ignore. But I am unable to do this. The dropdown gets populated with blanks. Following is the peice of code: var excel_cell = excel_file.ActiveSheet.Cells(i,1); alert(excel_cell); if(excel_cell=='undefined') ; else document.forms.form1.Products.add(new Option(excel_cell,excel_cell)); I am unable to check for undefined. How do I handle this ?? is there any smart way to do split, and ignore certain delimiters, like: Code: var s = "don't use ',' as part of data, some other text"; arr = s.split(","); // obviously don't want s to be splitted at ',' except chanhing delimiter ... ? Hi, I'd like to use the jQuery validation plugin as seen on the following example: http://docs.jquery.com/Plugins/validation#Example But it doesn't work properly if I use inline/in-filed labels. Any help is appreciated! Rain Lover I frequent a forum that has a pretty large community. There are a few users there I don't particularly care for. I would like to make a Greasemonkey compatible javascript code that would allow me to completely erase their posts from the page. What I want to happen is that every time Code: <li class="kpost-username"> <a rel="nofollow" title="" href="/index.php/component/kunena/profile/userid-80?Itemid=0" class="kwho-user">Rolepgeek</a> </li> appears it deletes the parent <table class="kmsg"> node. I know that I can find each of those code snippets with Code: document.getElementById('kpost-usernmae') however I am not sure how I would go about defining if it includes Code: <li class="kpost-username"> <a rel="nofollow" title="" href="/index.php/component/kunena/profile/userid-80?Itemid=0" class="kwho-user">Rolepgeek</a> </li> or not, nor am I sure on how to tell the code to delete the parent <table class="kmsg"> node when it does include it. I've been messing around a bit with some code, and I understand the general idea of how it should work, however I do not know the syntax in order to get it to work. Any help would be appreciated. HTML to a full post: Code: <table class="kmsg"> <tbody> <tr> <td class="kprofile-top"> <ul id="kpost-profiletop"> <li class="kpost-smallicons"> <span title="Gender: Unknown" class="kicon-profile kicon-profile-gender-unknown"></span> <a title="Click here to send a private message to this user." href="/index.php/component/uddeim/?task=new&recip=80&Itemid=213"><span alt="Click here to send a private message to this user." class="kicon-profile kicon-profile-pm"></span></a> <br> <div> <span class="kpost-userposts">Posts:334</span> </div> </li> <li class="kpost-personal"> Chaos will consume all... </li> <li class="kpost-avatar"> <a rel="nofollow" title="" href="/index.php/component/kunena/profile/userid-80?Itemid=0" class="kwho-user"><span class="kavatar"><img style="max-width: 72px; max-height: 72px" alt="" src="http://thekingdomsmc.com/media/kunena/avatars/resized/size72/users/avatar80.jpg" class="kavatar vbavnparnxybaoekjwjh"></span></a> </li> <li class="kpost-username"> <a rel="nofollow" title="" href="/index.php/component/kunena/profile/userid-80?Itemid=0" class="kwho-user">Rolepgeek</a> </li> <li class="kpost-userrank"> Merchant </li> <li class="kpost-userrank-img"> <img alt="" src="http://thekingdomsmc.com/components/com_kunena/template/default/images/ranks/rank3.gif"> </li> <li><span class="kicon-button kbuttononline-yes"><span class="online-yes"><span>NOW ONLINE</span></span></span></li> <li class="kpost-karma"> <span class="kmsgkarma"> Karma: -9 <a rel="nofollow" title="" href="/index.php/component/kunena/4-off-topic/karma/userid-80?do=decrease&pid=13229&0409ea1d6b1360d1a0a24ee6206c0bf4=1&Itemid=0"><span title="Smite" border="0" alt="Karma-" class="kkarma-minus"> </span></a> <a rel="nofollow" title="" href="/index.php/component/kunena/4-off-topic/karma/userid-80?do=increase&pid=13229&0409ea1d6b1360d1a0a24ee6206c0bf4=1&Itemid=0"><span title="Applaud" border="0" alt="Karma+" class="kkarma-plus"> </span></a> </span> </li> </ul> </td> </tr> <tr> <td class="kmessage-top"> <div class="kmsgbody"> <div class="kmsgtext"> Yeah. And it would be pointless, seeing as how I won't. </div> </div> <div style="display: none" class="kreply-form" id="kreply13229_form"> <form enctype="multipart/form-data" name="postform" method="post" action="/index.php/component/kunena/post?Itemid=0"> <input type="hidden" value="13229" name="parentid"> <input type="hidden" value="4" name="catid"> <input type="hidden" value="post" name="action"> <input type="hidden" value="1" name="0409ea1d6b1360d1a0a24ee6206c0bf4"> <input type="hidden" value="Shigan" name="authorname"> <input type="text" value=" To all non-bronies." maxlength="50" class="inputbox" size="35" name="subject"><br> <textarea cols="60" rows="6" name="message" class="inputbox"></textarea><br> <input type="checkbox" value="1" name="subscribeMe"> <i>Check this box to be notified of replies to this topic.</i> <br> <input type="submit" title="Click here to submit your message" value="Submit" name="submit" class="kbutton kreply-submit"> <input type="reset" title="Click here to cancel your message" value="Cancel" name="cancel" class="kbutton kreply-cancel"> <small>Note: BBcode and smileys are still usable.</small> </form> </div> </td> </tr> <tr> <td class="kbuttonbar-top"> <div> <div class="kmsgsignature"> With Order, come entropy,<br> With Life, comes death,<br> With Light, comes shadow.<br> <br> <div style="text-align: center">If one does not know Chaos, one does not realize the potential within themselves.</div> </div> </div> <div class="kmessage-editmarkup-cover"> <span class="kmessage-informmarkup"><a rel="nofollow" title="" href="/index.php/component/kunena/4-off-topic/13229-re-to-all-non-bronies/report?Itemid=0">Report to moderator</a></span> </div> <div class="kmessage-buttons-cover"> <div class="kmessage-buttons-row"> <a id="kreply13229" rel="nofollow" title="Quick Reply" href="/index.php/component/kunena/4-off-topic/13229-re-to-all-non-bronies/post?do=reply&Itemid=0" class="kicon-button kbuttoncomm btn-left kqreply"><span class="reply"><span>Quick Reply</span></span></a> <a rel="nofollow" title="Reply" href="/index.php/component/kunena/4-off-topic/13229-re-to-all-non-bronies/post?do=reply&Itemid=0" class="kicon-button kbuttoncomm btn-left"><span class="reply"><span>Reply</span></span></a> <a rel="nofollow" title="Quote" href="/index.php/component/kunena/4-off-topic/13229-re-to-all-non-bronies/post?do=quote&Itemid=0" class="kicon-button kbuttoncomm btn-left"><span class="quote"><span>Quote</span></span></a> </div> </div> <div class="kpost-thankyou"> <a rel="nofollow" title="I want to thank you for this message!" href="/index.php/component/kunena/4-off-topic/thankyou?pid=13229&0409ea1d6b1360d1a0a24ee6206c0bf4=1&Itemid=0" class="kicon-button kbuttonuser btn-left"><span class="thankyou"><span>Thank You</span></span></a></div> </td> </tr> </tbody> </table> Hi, I'm trying to write/find a regular expression for finding ampersands but not HTML entites I have this which finds entities but can't figure out how to ignore entities and return unmatched "&" Code: &[^\s]*; Test string: Code: This is sample test containing a bunch of & and entities. Do you shop at: M&S? &x#1234; I want to HTML encode the non-entity ampersands for insertion into XML e.g. "bunch of & and" --> "bunch of & and" Any help will be greatly appreciated Cheers Al Hi, Does anyone know how to make a javascript regex ignore new lines? I have this Code: html = html.replace(/<!--(.*?)-->/gi, ''); // HTML comments which matches single line comments like - Code: <!-- this is a comment --> but not this - Code: <!-- This is a comment on multiple lines --> I think the answer lies with [\s\S] but I can't get it to work e.g. - Code: html = html.replace(/<!--(.*[\s\S]?)-->/gi, ''); // HTML comments Any help will be greatly appreciated Cheers Al Moved to a diff board by topic started...
Hi I am doing validation on a form, but instead of throwing an alert on empty fields I want to highlight those fields indicating error. if all are empty, then i would like to show only 1 generalized error message "Pls. fill the highlighted textboxes.". how do i do this and thanks in advance. i get this error when ever i try to process the form: There was a SyntaxError: Unexpected token < error due to an parsererror condition. Javacsipt/jquery: $(document).ready(function(){ $("#slide").click(function(){ $("#inner-wrapper").slideToggle(); }); $('form #response').hide(); $('#submit').click(function(e){ e.preventDefault(); var valid = ''; var required = ' is required'; var name = $('form #name').val(); var email = $('form #email').val(); var fname = $('form #fname').val(); var femail = $('form #femail').val(); var message = $('form #message').val(); var honeypot = $('form #honeypot').val(); var humancheck = $('form #humancheck').val(); //Error checking if (name == '' || name.length <=2) { valid = '<p>Your name' + required + '</p>'; } if (!email.match(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/)) { valid += '<p>Your email' + required + '</p>'; } if (fname == '' || fname.length <=2) { valid += '<p>Your friend\'s name' + required + '</p>'; } if (!femail.match(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/)) { valid += '<p>Your friend\'s email' + required + '</p>'; } if (message == '' || message.length <=5) { valid += '<p>A message' + required + '</p>'; } if (honeypot != 'http://') { valid += '<p><center>Spambots are not allowed.</center></p>'; } if (humancheck != '') { valid += '<p><center>A human user' + required + '</center></p>'; } if (valid != '') { $('form #response').removeClass().addClass('error') .html('<strong>Please correct the errors below.</strong>' + valid).fadeIn('2000'); }else { $('form #response').removeClass().addClass('processing').html('<center>Working...</center>').fadeIn('2000'); var formData = $('form').serialize(); submitForm(formData); } }); }); function submitForm(formData) { $.ajax({ type: 'POST', url: 'emailfriend.php', data: formData, dataType: 'json', cache: false, timeout: 7000, success: function(data) { $('form #response').removeClass().addClass((data.error === true) ? 'error' : 'success') .html(data.msg).fadeIn('fast'); if ($('form #response').hasClass('success')) { setTimeout("$('form #response').fadeOut('slow')", 5000); } }, error: function(XMLHttpRequest, textStatus, errorThrown) { $('form #response').removeClass().addClass('error') .html('<p>There was a <strong>' + errorThrown + '</strong> error due to an <strong>' + textStatus + '</strong> condition.</p>').fadeIn('fast'); }, complete: function(XMLHttpRequest, status) { $('form')[0].reset(); } }); }; php file PHP Code: <?php error_reporting(E_ALL ^ E_NOTICE); sleep(3); $name = stripslashes($_POST[name]); $email = stripslashes($_POST[email]); $fname = stripslashes($_POST[fname]); $femail = stripslashes($_POST[femail]); $message = stripslashes($_POST[message]); $honeypot = $_POST[honeypot]; $humancheck = $_POST[humancheck]; if ($honeypot == 'http://' && empty($humancheck)) { $error_msg = ''; $reg_exp = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/"; if (!preg_match($reg_exp, $email)) { $error_msg .= "<p>A valid email is required</p>"; } if (!preg_match($reg_exp, $femail)) { $error_msg .= "<p>A valid email is required</p>"; } if (empty($name)) { $error_msg .= "<p/>Please provide your name</p>"; } if (empty($fname)) { $error_msg .= "<p/>Please provide your name</p>"; } if (empty($message)) { $error_msg .= "<p>A message is required.</p>"; } if (!empty($error_msg)) { $return['error'] = true; $return['msg'] = "<h3>Oops! Looks like you missed a few fields.</h3>".$error_msg; echo json_encode($return); exit(); }else { $return['error'] = false; $ref=@$HTTP_REFERER; /////Message at the top of the page showing the url//// $header_message = "Hi $fname \n Your friend $name requested you to visit this page at \n $ref \n"; /// Body message prepared with the message entered by the user //// $body_message =$header_message."\n".$message."\n"; // IP address of visitor is added to message, you can remove it if not required.// $body_message .="\n Sent from http://www.separatethescams.com"; //// Mail posting part starts here ///////// $headers=""; //$headers = "Content-Type: text/html; charset=iso-8859-1\n".$headers; // Un comment the above line to send mail in html format $headers4=$email; // Change this to change from address $headers.="Reply-to: $headers4\n"; $headers .= "From: $headers4\n"; $headers .= "Errors-to: $headers4\n"; $subject="$name visit this site!"; mail($femail,$subject,$body_message,$headers); $return['msg'] = " <b><p><center>Thanks for spreading the word! :) " . "<font color='red'>" .$name . "</font>" . " </p>" . "</b>" . "</center>"; echo json_encode($return); } }else { $return['error'] = true; $return['msg'] = "<h3><center>0ops there was a problem submitting the data. Please try again!</center></h3>"; echo json_encode($return); } ?> html file <html> <head> <link rel="stylesheet" href="ajaxform/form.css" type="text/css" media="screen"/> </head> <body> <div id="wrapper"> <h3 id="slide">Email This Page To a Friend</h3> <hr></hr> <div id="inner-wrapper"> <form id="my_form" action="ajaxform/emailfriend.php" method="post"> <div id="response"><!--This will hold error message and response from server. --></div> <div class="inputs"> <p> <label>Name   ; </label> <input name="name" type="text" placeholder="Your Name" class="required" id="name" size="30" /> </p> </div> <div class="inputs"> <p> <label>Email &nbs p; </label> <input name="email" type="text" placeholder="Your Email" class="required" id="email" size="30" /> </p> </div> <div class="inputs"> <p> <label>Friend's Name </label> <input name="fname" type="text" placeholder="Friend's Name" class="required" id="fname" size="30" /> </p> </div> <div class="inputs"> <p> <label>Friend's Email </label> <input name="femail" type="text" placeholder="Friend's Email" class="required" id="femail" size="30" /> </p> </div> <div class="inputs"> <p> <label id="msg">Message </label> <textarea name="message" cols="24" rows="5"type="text" placeholder="Message To Friend" class="required" id="message"></textarea> </p> </div> <div class="button"> <input name="submit" type="submit" id="submit" value="EMAIL PAGE" /> </div> <div class="inputs"> <input type="hidden" name="honeypot" id="honeypot" value="http://" /> <input type="hidden" name="humancheck" id="humancheck" class="clear" value="" /> </div> </form> </div> <!-- inner-wrapper end --> </div> <script type="text/javascript" src=" https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript" src="ajaxform/ajax_submit.js"></script> </body> </html> I've tried a couple of different scripts, and I'm getting the same result, so I know I must just be missing something. I'm very new to this, so I'm not figuring it out. I want a text box to show the results of an increment counter. Every time I click a button, the number in the text box increments by one. I know it sounds simple, but it's not working. Help? My code is below: Code: <style type = "text/css"> .tbsize { width: 30px; border: 3px; padding: 10px } </style> <script type="text/javascript"> var i=0; function increase() { ++i; } </script> </head> <body> <div id = "tbsize" class = "tbsize"> <form onsubmit = "return false" action = ""> <table> <td><input type = "text" id = "addone" /></td> <td><input type = "submit" value = "Click to add One" onclick="increase()"></td> </table> </form> </div> </body> </script> Hey guys, Working on a large project. Ive created a form that when an anchor is clicked it calls the following javascript. This code executes fine in FF and creates a new select box, input box, and delete anchor. When i attempt this code in IE 8, an error occurs. The error message below and referes to the lines in which i have used the newField array. Code: <script type="text/javascript"> var counter = 0; function moreFields() { var newFields = document.getElementById('rowline').cloneNode(true); var insertHere = document.getElementById('inputgroup'); var newField = newFields.childNodes; counter = document.getElementsByTagName('select').length; newField[2].name = 'item' + counter; counter = document.getElementsByTagName('input').length; newField[5].name = 'amount' + counter; newField[7].style.display = 'block'; insertHere.parentNode.insertBefore(newFields,insertHere); } </script> Error: Object doesn't support this property or method Im guessing this refers to the attempt to use .name/.style . Does anyone know why this is the case or an alternative way to do this? Thanks. Matthew King Hi. I've just finished up a web design I've been working on and of course it looks and works great in FF, but has problems in IE. My question is, how do you see what's wrong in IE? I know how to fix the html/css but how do I see what's going wrong with the javascript and php? Is there link in IE where I can see the errors? Thanks in advance. I have the following code for determining 30 year amortization for fha and conventional loans: Code: function calc(){ var alrt=""; if (document.getElementById("down").value==""){ alrt+="Down Payment\n"; } if (!document.getElementById("con").checked && !document.getElementById("fha").checked){ alrt+="Loan Type"; } if (alrt!=""){ alert("You Must Fill Out the Following Fields:\n"+alrt); } else { doAmb(); } } function doAmb(){ var pur=purchasePrice; var down=eval(document.getElementById("down").value); if (document.getElementById("type").selectedIndex==1){ downPay=down*.01; downPay=downPay*pur; } else { downPay=down; } var pay=pur-downPay; if (document.getElementById("fha").checked){ pay=pay*(1.0225); } amt=getPayment(pay,360,interestRate); writeData(pur,downPay,amt); } function getPayment(a,n,p) { var acc=0; var base = 1 + p/1200; for (i=1;i<=n;i++) { acc += Math.pow(base,-i); } return a/acc; } function writeData(pp,dp,mp){ document.getElementById("purc").innerHTML=Math.round(pp*100)/100; document.getElementById("mon").innerHTML=Math.round(mp*100)/100; document.getElementById("downP").innerHTML=Math.round(dp*100)/100+" ("+(Math.round(((dp/pp)*100)*100)/100)+"%)"; document.getElementById("loan").innerHTML=Math.round((pp-dp)*100)/100; document.getElementById("inter").innerHTML=interestRate; document.getElementById("ins").innerHTML=insurance; document.getElementById("tax").innerHTML=tax; document.getElementById("tot").innerHTML=Math.round((tax+insurance+mp)*100)/100; document.getElementById("sptype").innerHTML=((document.getElementById("con").checked)?"Conventional": "FHA"); document.getElementById("inputArea").style.display="none"; document.getElementById("outputArea").style.display="block"; } function showIn(){ document.getElementById("cover").style.display="block"; document.getElementById("inputArea").style.display="block"; } It works 100% perfectly in Firefox, but in Internet Explorer, it won't do anything. Also, I know there may be some missing variables, those are in a separate JS file. Edit: Also, just discovered that it works fine when used inline, but loaded from an external file, it returns an "Invalid Character" error. If you go to: http://www.five-nine.net/index2/index.html and click on "Go Ahead what ..... info@five-nine.net" And try to submit the form, it will work in every browser except IE6, IE7, & IE9, (I don't know why IE8 is so different than the rest but w/e)... However I don't see any errors on in the JavaScript. Does anyone know why this would happen in just those three browsers? The validator showed up these errors on my site. They are from a script, but I know very limited javascript to correct it, to me it seems to be OK. 1. Line 15, Column 23: character "<" is the first character of a delimiter but occurred as data for (var i = 0; i < d.length; ++i) { This message may appear in several cases: * You tried to include the "<" character in your page: you should escape it as "<" * You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&", which is always safe. * Another possibility is that you forgot to close quotes in a previous tag. 2. Error Line 15, Column 23: StartTag: invalid element name for (var i = 0; i < d.length; ++i) { Code: <script type="text/javascript"> window.onload = function() { if (!NiftyCheck()) { return; } Rounded("div#nifty", "#666", "#FFF", 30, 30); } function adjustRadius() { d = getElementsBySelector("div.rounded"); for (var i = 0; i < d.length; ++i) { d[i].parentNode.removeChild(d[i]); } var x = document.getElementById("radiusx").value; var y = document.getElementById("radiusy").value; Rounded("div#nifty", "#666", "#FFF", x, y); return false; } </script> Does anyone know why these errors are coming up on the WC3? here is the link where the problem persist http://www.ornusweb.com/what_we_done.html I have mixed 2 scripts the light box script(lightbox.js) and scroller script(scriptaculous.js) the page only works with ie and in other browsers it opens as an image(light box wont work) the errors say 1st error> uncaught script.aculo.us requires the prototype javaScript frame work >1.4.0 scriptaculous.load (anonymous function) 2 error > uncaught typeErrorbject function object(){[native code]} has no method 'extends' (anonymous function) can some one help me solve these problem's On the 'Edit Profile' page of my eCommerce Wordpress Theme (http://www.projectdisobey.com/disobeyclothing), no error message appears when I do any of the following in the ''New Password' and 'Confirm New Password' text fields: 1. 'New Password' and 'Confirm New Password' do not match. 2. 'Confirm New Password' field is left empty. 3. New password is less than 5 characters. 4. New password is exactly the same as the current password. This is the script: Code: <script language="javascript" type="application/javascript"> function chk_form_pw() { if(document.getElementById('new_passwd').value == '') { alert("<?php _e(ENTER_NW_PW_JS_MSG) ?>"); document.getElementById('new_passwd').focus(); return false; } if(document.getElementById('new_passwd').value.length < 4 ) { alert("<?php _e(ENTER_NW_PW_MIN_JS_MSG) ?>"); document.getElementById('new_passwd').focus(); return false; } if(document.getElementById('cnew_passwd').value == '') { alert("<?php _e(ENTER_CONFIRMNW_PW_JS_MSG) ?>"); document.getElementById('cnew_passwd').focus(); return false; } if(document.getElementById('cnew_passwd').value.length < 4 ) { alert("<?php _e(ENTER_CONFIRMNW_PW_MIN_JS_MSG) ?>"); document.getElementById('cnew_passwd').focus(); return false; } if(document.getElementById('new_passwd').value != document.getElementById('cnew_passwd').value) { alert("<?php _e(ENTER_NW_AND_CONFIRM_PW_SAME_JS_MSG) ?>"); document.getElementById('cnew_passwd').focus(); return false; } } </script> I'd be extremely appreciative if anybody could help me fix the script so that it works as it is meant to. Javascript is not something I'm particularly familiar with... Thanks in advance! ****ING FORUM PIECE OF ****, just wrote a whole post about my error and got taken to login when I clicked submit and the post is gone now, great, thanks for caching the tags and the title, really needed those...................flsdkjflsdkfjsd
I have a loop that originally printed out a day, in a table, that linked to a new page. Code: out.println("<th height=100><a href=eventPage.jsp?month="+(n+1)+"&day="+d+">" + d + "</a>"); This works fine but now I want to instead have it be a link a page thats a pop up. The code I have now is as follows Code: out.println("<th height=100><a href="eventPage.jsp?month="+(n+1)+"&day="+d"" onclick="popUp(this.href);return false"> + d + "</a>">); and Code: <script type="text/javascript"> function popUp(URL) { <!-- window.open(URL,'width=300,height=300'); //--> } </script> I can not seem to find where I am going wrong. Any help would be appreciated. |