JavaScript - Search For Special Characters
First of all thanks for all the help you are providing.
I am looking to alert a user if they type in an character that I am going to not allow for their input box Code: function IsExc (str){ var AllChr = "~ # $ % ^ { } [ ] ' ,"; var AC= AllChr.split(" "); var SC = 0; for (SC=0; SC <= AC.length; SC++){ var ACS = AC[SC]; if (str.search(ACS) >0 ) alert ('Cannot use the characters' + AllChr ) } } For reasons I don't understand the code will not work Similar TutorialsIs there an inbuilt function in javascript to convert web characters like
Code: & back to '&' for use in a search text field? I am trying to get a series of dynamic digits from page one to page two via the url. below are the codes have been able to come up with. The problem am having however is that the variables from the first page contains two other characters mainly (=) and (on). therefore, the result i get is like this; 2=on43=on6=on76=on98=on34=on etc What i want displayed are simply the numbers without these two characters. Code: <script> if(window.location.search){ var query = window.location.search.substr(1); var data = query.split("&"); for (var i = 1; i <= 9; i++){ var data = datas[i].split("="); if (unescape(data[1]) == key_str); data.replace(/\=/g," "); } } </script> below is the code that writes the output Code: <script> for (i = 1; (i <= 9); i++) { document.write(data[i]); data[i]="" } </script> thanks I have been using code such as Code: a=a.replace(/ /g,''); b=b.replace(/;,/g,';'); to eliminate spaces in a string, as well as converting things like ";," to ";" in strings. Several instances of these replacements will have to occur in the strings. Unfortunately, I cannot make it work for converting two commas into one or for eliminating line breaks. Does anyone know how to do this (preferably without using "while")? In this case, Let's take Google Search as example: The code is JScript .NET, which is basically a .NET version of Javascript. Regardless of language, Anyone with appending type of skill can answer my question. This code is used in Fiddler(It's a Man-in-the-middle proxy) Code: if (oSession.uriContains("&q=")) // oSession is a Fiddler object session // uriContains() function, checks for case-insensitive string from the URI { var str = oSession.fullUrl; var sAppend = "test1+test2+test3"; if (!oSession.uriContains(sAppend)) { oSession.fullUrl = str.replace( "&q=","&q="+sAppend); } } For those who are confused, It says, If &q= is present in the URI, replace/append &q= with &q=test1+test2+test3 Problem: It appends test1+test2+test3 instantly, when it sees &q= in the URL. Basically, how do I make it wait until I click the submit/search button Thank you. Update: I heard about Onsubmit() event, but not really familiar with it. How do I use it? like, should I go to google source page and edit the form id? Also, Any other methods besides Onsubmit()? Hello, I need to improve an existing JavaScript redirect by adding a second redirect based on information contained in the URL. First I will outline the situation, then the specifics: I designed a Realtor website using Joomla 1.5 a few years ago. I will call this SITE-1. The site, SITE-1, displays real estate listing from another site (SITE-2) using iFrames. So the listings from SITE-2 appear to be integrated into the pages of SITE-1. Someone shopping for real estate signs up to be notified of new listings. A new listing comes out and an email is sent to the user with a link to the listing - only the link to the listing is located on SITE-2. So I have been using a JavaScript redirect on SITE-2 that asks the question - "is this in an iFrame" ... if no - redirect to SITE-1 and iframe the results. SITE-1 is ready to receive and parses the new URL: Code: <script language="JavaScript"> <!-- // Start if (window == top) { tops = top.location.href location.replace('http://www.SITE-1.com/index.php?option=com_content&view=article&id=42&Itemid=137&iframe='+tops); } // End --> </script> Now, I have a new problem. I don't have access to SITE-2, I only get to submit a template to them. One of the possible links sent to users from SITE-2 contains a variable in the URL: &id=, followed by a 3 digit number. So the full URL might look like this: http://www.site-2.com/index.php?pg=delacct&id=570 I cannot redirect this to the normal page on SITE-1 because Joomla already uses id=, and it just gets confused and drops a 404 page. Instead I need the code I posted above, to FIRST check for id=. If it exists - go to PAGE-A. If not - then do what the script already does as posted above (we'll call that PAGE-B). Can anyone help? (hopefully I explained that so it can be understood) Thanks, --Kevin Hello, this is only for specialist in javascript. I searching a very special javascript, which can be done expire a web site after some identified time(i.e 10days, 20days....). I have made a web site. now i'm looking for, the site expire(or not working at hosting) within 10 days. can I find any special javascript like this? I am trying to make a very simple form so a user can enter some text then be redirected to a page that uses that text in the URL. So far I have this working using window.open but the ? and & in the URL show up as & # 0 3 8 ; here is the code in the body; Code: <script type="text/javascript"> /* <![CDATA[ */ function orderBlog() { var subDomain = document.blogDomain.domainEntered.value; window.open("http://mydomain.com/portal/cart.php?=add&pid=15&domainoption=subdomain&sld=" + subDomain + ""); } /* ]]> */ </script> <form name='blogDomain' onsubmit="orderBlog();"> <input type='text' name='domainEntered' size='60' style='width:100px;' /> .mydomain.com <input type="submit" value="Get Your Site!" /> </form> but for some reason that goes to the URL mydomain.com/portal/cart.php & # 0 3 8 ; =add & # 0 3 8 ; pid=15 & # 0 3 8 ; domainoption=subdomain & # 0 3 8 ; sld=XXXXXXXX when using firfox, ie7 works fine I am trying to make a page that shows a daily special for a *fake* pizza place. I want it to detect the day it is, and write the special within the document as an H1 heading or something like that. For testing I have it setup to do an Alert, but it alerts me of the monday special today which is correct, but if I change my system time to another day it doesn't work. Does it work like that or is there a better way to test it? Here is the code, there is a <body onload="getToday()"> in place Code: function getToday() { var d = new Date(); var weekday=new Array(7); weekday[0]="Sunday"; weekday[1]="Monday"; weekday[2]="Tuesday"; weekday[3]="Wednesday"; weekday[4]="Thursday"; weekday[5]="Friday"; weekday[6]="Saturday"; if (weekday[d.getDay()] = 0) { alert("Buy one Pizza get a second for only $5"); } else if (weekday[d.getDay()] = 1) { alert("Order of Breadsticks for $1"); } else if (weekday[d.getDay()] = 2) { alert("Order of Cinnamon Sticks for $1"); } else if (weekday[d.getDay()] = 3) { alert("Free Two Liter with Pizza Order"); } else if (weekday[d.getDay()] = 4) { alert("Order of Hot Wings for $1"); } else if (weekday[d.getDay()] = 5) { alert("Orders of Breadsticks, Cinnamon Sticks, and 2 liter for $3 with"); } else if (weekday[d.getDay()] = 6) { alert("Breadsticks and a two liter for $1"); } } </script> In Brno, 07.06.2011 Hello everybody, i really need your help with one issue. I have got one page running under Wordpress and i would like to add some countdown to widget to show when i will be again online. for example: I am online every working day (monday - friday) from 08:00 AM to 04:30 PM. So it would be nice to show to my subscribers when i would be online again. So lets think about that is Thuesday 07:00 PM, so on my page would be visible this: "I will be back in 13 hours, 00 minutes, 00 seconds" Or in Saturday at 07:00 PM there will be written: "I will be back in 37 hours, 00 minutes, 00 seconds" I would really apreciate every help, thank you in advance! Stefan alias "Scharfheimlich" hi, I would like to change my validation page so that a user cannot use special characters in the form, here is my code below Code: jQuery("#full_name").validate({ expression: "if (VAL) return true; else return false;", message: "Please enter your name" }); jQuery("#name").validate({ expression: "if (VAL.match(/^[^\\W][a-zA-Z\\_\\-\\.]+([a-zA-Z\\_\\-\\.]+)*\\@[a-zA-Z0-9_]+(\\.[a-zA-Z0-9_]+)*\\.[a-zA-Z]{2,4}$/)) return true; else return false;", message: "Please enter your name" }); Hi Everyone! I have a website that I'm designing where I have the need to search multiple sites at specific times. By this I mean that In some cases, we would want to search only the internet using google, or only search the site that I've created (which currently uses the jse_search.js solution), or only our company's website. I currently have four different search boxes that will search either the internet, the internal site, a separate internal site, or a third-party website, which all working fine. The problem is that the search boxes take up quite a bit of space, and the layout is becoming cumbersome. Is there a way in Javascript I could use a single search box and a drop-down list to select which method to use? The code I'm currently using is below. With the exception of the Google search function, I've modified some of the site names to general site names and paths to preserve the company's anonymity: Code in the <head> tag: Code: <script language="JavaScript1.3" type="text/javascript" src="jse_form.js"> </script> Code in the <body> tag: Code: <!--Begin Internal Site Search 1!--> <div> <p style="text-align: center;"> <table border="0" cellpadding="0"> <tr><td><form name="jse_Form" onsubmit="search_form(jse_Form);return false"> <input type="text" name="d" size="30"> </tr></td> <tr><td> <input type="button" value="Internal Site Search 1" onclick="search_form(jse_Form)"> </form> </tr></td> </table> <!--End Internal Site Search 1!--> <!--Begin Internal Site Search 2!--> <div> <p style="text-align: center;"> <table border="0" cellpadding="0"> <tr><td> <!--webbot bot="Search" S-Index="all" S-Fields S-Text="Search for:" I-Size="20" S-Submit="Start Search" S-Clear="Reset" S-TimestampFormat="%m/%d/%Y" TAG="BODY" b-useindexserver="1" startspan --> <form action="http://sitesearch2.idq" method="POST"><input type="text" name="UserRestriction" size="30" value> </tr></td> <tr><td style="text-align: center;"> <input type="submit" value="Internal Site Search 2"></form> </form> <!--webbot bot="Search" i-checksum="4210" endspan --> </td></tr> </table> </div> <!--End Internal Site Search!--> <!--Begin Google Search!--> <form method="get" action="http://www.google.com/search"> <div> <p style="text-align: center;"> <table border="0" cellpadding="0"> <tr><td> <input type="text" name="q" size="30" maxlength="233" value="" /> </tr></td> <tr><td align="center"> <input type="submit" value="Google Search" /></td></tr> </table> </div> </form> <!--End Google Search!--> <!--Begin Third Party Search!--> <form id="keywordSearchForm" method="get" action="http://www.site3.html"> <div> <p style="text-align: center;"> <table border="0" cellpadding="0"> <tr><td> <input class="input" type="text" name="keyword" size="30" /> </tr></td> <tr><td align="center"> <input type="hidden" name="origin" value="keywordsearch" /><input id="go" class="button" tabindex="0" type="submit" value="Third Party Search" /> </td></tr> </table> </div> </form> <!--End Third Party Site Search!--> Hi experts, is it possible via Javascript to search certain websites with certain keywords without having to use specific search engines? example search only the following: 1. www.yyy.com 2. www.aaa.com 3. www.zzz.com for the keyword "Laminat" and open the sites accordingly. thx Hallo. I am a total newbie to JavaScript coding, but I would like to have a price calculator on our internal website. It should calculate the square meter of the product and then multiply it with the square meter price, multiply it with quantity and then plus it with the startup cost. But... if the square meter extend 20 m2 the square meter price should be lower, and also lower when it hit 50 m2. And at 100 m2 it should write that you have to contact sales department. Can this be done with JavaScript? Here is an example: 6 pieces of 2 x 4 meter. 2x4 = 8 m2 6x8 = 48 total m2 48 m2 x price2 x startup = total price I really hope that someone can help me... //Daniel Hey. Yes, I'm just starting at the beginning and what I'm trying to understand today is adding special characters such as line break, quotes, etc. into Javascript. I'm missing something, however. Can someone please assist? What I'm trying to do is add a line break without having it show /n on the screen. My Code: <html> <head> <title>Exercise 6-20</title> </head> <body><pre> ********* *** * *\n * * * * *** * *\n * * * * ***** * *\n * * * * * * *\n * * * * * * *\n * * * * * * *\n * * * * * * *\n * * * * * * *\n * * * * * * *\n * * * * * * *\n * * * * * * *\n ********* *** * * *\n </pre> </body> </html> Thank you, H HELLO FELLAS, can someone please show me where get drop down menu like the one goldman sachs uses. take a look please: http://www2.goldmansachs.com/ help is much appreciated julio Hi guys (and ladies) I am a bit stuck and hope this community might shine a light, or even better can supply me with a solution. I want to do the following: - Having an ordinary webpage containing links - I will link the links with files (word processing files , MS Word, Open Office writer, wordpad or similar) - Now when clicked on the link I want the 'system' to copy the contents of the linked file to the windows clipboard, so when clicking paste, the text from the file is pasted wherever I want. To make clear, I don't want any word processing app to open, just click the link and paste where it needs to be. Possible?? MOST LIKELY but I have no clue how. Any chance someone might know the answer??? I am looking forward to the replies! Thanks PvL |