JavaScript - Prevent The Others Type Using Jquery
Code:
1 ,<input id="14sq-und-0-value" size="12" maxlength="10" class="form-text" type="text"> 2 ,<input id="510sq-und-0-value" size="12" maxlength="10" class="form-text" type="text"> 3 ,<input id="1119sq-und-0-value" size="12" maxlength="10" class="form-text" type="text"> 4, <input id="20jsq-und-0-value" size="12" maxlength="10" class="form-text" type="text"> 5 ,<input id="oneyear-und-0-value" maxlength="10" class="form-text" type="text"> 6 ,<input id="twoyear-und-0-value" maxlength="10" class="form-text" type="text"> 7 ,<input id="threeyear-und-0-value" size="12" maxlength="10" class="form-text" type="text"> 8 <input id="vpssq-und-0-value" size="12" maxlength="10" class="form-text" type="text"> 9 <input id="500zh-und-0-value" size="12" maxlength="10" class="form-text" type="text"> 10 <input id="1000zh-und-0-value" size="12" maxlength="10" class="form-text" type="text"> 11 <input id="1500zh-und-0-value" size="12" maxlength="10" class="form-text" type="text"> now, i want to do, if the editor type content to 1, 2, 3 4 input box and finished namely the 1 ,2,3 4have value , then he can't type anything to the rest. if the 5,6,7, input box has value. then can't type anything to the rest. if the 8, input box has value. then can't type anything to the rest. if the9,10,11, input box has value. then can't type anything to the rest. Similar TutorialsSo, i have this code which retrieves php files for me using jquery and id love to get it working with Jquery history plugin. I tried modifying the code i got from the ajax demo to work for me, but i just couldnt do it as i do not know any javascript really.. ( actually what i tried was simply to change "#ajax-links a" to "#menu li a" and .html to .php ..but nothing.. :rolleyes: Id be very gratefull if someone would help me out with this one. All related code can be found bellow (the ones that should be needed anyways): This is the code that retrieves php files inside "#content" when item from "#menu li a" with the specified id is clicked Code: $(document).ready(function(){ //References var change = $("#menu li a"); var loading = $("#loading"); var content = $("#content"); //Manage click events change.click(function(){ //show the loading bar showLoading(); //load selected section if(this.id == "home") { change.load(this.className='current-page'); content.slideUp(); content.load("pages/index.php", hideLoading); content.slideDown(); } else if(this.id == "secondpage") { change.load(this.className='current-page'); content.slideUp(); content.load("pages/secondpage.php", hideLoading); content.slideDown(); } else { //hide loading bar if there is no selected section hideLoading(); } }); //show loading bar function showLoading(){ loading .css({visibility:"visible"}) .css({opacity:"1"}) .css({display:"block"}) ; } //hide loading bar function hideLoading(){ loading.fadeTo(1000, 0); }; }); Heres the structure of the menu/content Code: <ul id="menu"> <li><a id="home" class="normal" href="#Home"></a></li> <li><a id="secondpage" class="normal" href="#Secondpage"></a></li> </ul> <div id="content"> <ul id="sec-menu"> <li><a id="link1" class="normal" href="#">Link1</a></li> <li><a id="link2" class="normal" href="#">Link2</a></li> </ul> </div> Heres the code that jquery history plugin uses in demo for ajax Code: jQuery(document).ready(function($) { function load(num) { $('#content').load(num +".html"); } $.history.init(function(url) { load(url == "" ? "1" : url); }); $('#ajax-links a').live('click', function(e) { var url = $(this).attr('href'); url = url.replace(/^.*#/, ''); $.history.load(url); return false; }); }); hi, i have a jquery problem... this script is not working with jquery-1.4.2.min, but it works with jquery-1.2.6.min.js, can anyone help me???the script is the above: (it is not working the tab actions, the slideout works...) http://www.benjaminsterling.com/wp-c...es/sidetab.htm the javascript code is the above: PHP Code: var jqsideTabs; var tabs, h = 50, r = 0,ra = 0; $(document) .ready(function(){ jqsideTabs = $('#sideTabs').addClass('closed'); tabs = jqsideTabs .find('.tab h3') .clone() .appendTo(jqsideTabs) .each(function(i){ var that = $(this), cls = '',ow,newThis, newEl; if( i == 0 ) cls = ' active'; newEl = $('<a href="#" class="tabLinks'+cls+'">' + that.text() + '</a>'); that.replaceWith(newEl); ow = newEl.outerWidth(); if( i == 0 ) ra = ow; else r = ow; h = newEl.css({'top':h , 'right': -ow }).height() + h; newThis = newEl.get(0); newThis.jq = newEl; newThis.i = i; newEl.click(function(){ var el = this.jq; if( jqsideTabs.hasClass( 'closed' ) ){ jqsideTabs.removeClass('closed'); } else if( !jqsideTabs.hasClass( 'closed' ) && el.hasClass('active') ){ jqsideTabs.addClass('closed'); } el .siblings() .removeClass('active') .css({'right': -r }) .end() .addClass('active') .css({'right': -ra }); tabs.eq( this.i ).show().siblings('.tab').hide(); return false; }); }) .end() .parent() .eq(0) .addClass('active') .end() .filter(':not(:eq(0))') .hide() .end(); jqsideTabs.bind("mouseleave",function(){ jqsideTabs .animate({left:-310}, 'fast', function(){ jqsideTabs.addClass('closed').removeAttr('style'); }); }); }); and the html file is: [HTML] <div id="sideTabs"> <div class="tab"> <h3>Tab 1</h3> <div class="gut"> <p>Some text</p> </div> </div> <div class="tab"> <h3>Tab 2</h3> <div class="gut"> <ul> <li>link</li> </ul> </div> </div> <div class="tab"> <h3>Tab 3</h3> <div class="gut"> <ul> <li>link</li> </ul> </div> </div> </div> [/HTML] the problem is that the tab button works, but the content doesnt change...in all of tabs showing the same text(showing all tbas content).... can anyone help...please..... i keep getting the error GET http://code.jquery.com/jquery.min.map net::ERR_TOO_MANY_REDIRECTS & Failed to load resource: net::ERR_TOO_MANY_REDIRECTS when i load my page...and the havascript doesn't work properly on ym page...how do i resolve this. thanx in advance var s="attr" var i=$(s) // jQuery(elem).attr(attr,eval("elm"+attr)); jQuery(elem).$(s)(attr,eval("elm"+attr));//i tried this. how to assign a variable name in the above code(in place of s) so that i need to add an attribute to the element "elem". Hello. I'm using the keyup event for an input box to check for the Escape key (keyCode 27). I'm then using this to hide a related select element. It works okay apart from IE(8) of course . How can I prevent IE carrying on with its normal Escape behaviour? If tried a number of things, most recently: Code: e.cancelBubble = true; if ( e.stopPropagation ) e.stopPropagation(); return false; but it, IE, is insistant. I tried switching to 'keydown' but it went a bit wonky.. Andy. Hello, Is there anyway to prevent images, words, divisions, etc from being selected? Also if something is selected is there a way to deselect? Thanks! I need to change input type="text" to input type="password" via JavaScript Code: <form id="login" action="#" method="post"> <input id="username-field" type="text" name="username" title="Username" onmousedown="javascript:this.value=''; javascript:this.focus();" value="Username" tabindex="1" /> <input id="password-field" type="text" name="password" title="Password" onmousedown="javascript:this.value=''; javascript:this.type='password'; javascript:this.focus();" value="Password" tabindex="2" /> <input type="submit" name="submit" value="sign in" tabindex="3" /> </form> This works in Firefox and Safari but not IE So then I tried this code Code: <script type="text/javascript"> function passit(ip){ var np=ip.cloneNode(true); np.type='password'; if(np.value!=ip.value) np.value=ip.value; ip.parentNode.replaceChild(np,ip); } </script> <form id="login" action="#" method="post"> <input id="username-field" type="text" name="username" title="Username" onmousedown="javascript:this.value=''; javascript:this.focus();" value="Username" tabindex="1" /> <input id="password-field" type="text" name="password" title="Password" onmousedown="javascript:this.value=''; passit(this.form[0]); javascript:this.focus();" value="Password" tabindex="2" /> <input type="submit" name="submit" value="sign in" tabindex="3" /> </form> This does what I need but turns the username type to password field not the password box Please can somone help! Hey! I searched a while on the web for this but i didn't find a solution that really worked. So is there a way how i can prevent IE9 from scrolling when i use the arrow keys? I have a tracking ad at the bottom of my site. (no iframes). how do I know and/or prevent that tracking ad from popping up a popup? They are not suppose to, but I suspect they do. Is there a way to track this, or perhaps prevent them from popping the popup from within my page? I have access to various libraries, prototype/jquery etc.. so if there is a func/method in those, I could use too. How do I prevent my Link from disappearing?? When I click on the link, "Click Here" It display, "Look At Me!!" but the link, "Click Here" is GONE Is there a way to keep my link, "Click Here" from disappearing? So when I click on the link, "Click Here" the content, "Look At Me!!"should display as well. thanks Here are my codes Code: <html> <head> <script type="text/javascript"> function display() { document.writeln("Look At Me!!"); } </script> </head> <body> <a href="google.com" onClick="display()">Click Here</a> </body> </html> I retrieve a list of links from a database using ajax, then I assign them to the innerHTML property of a div whose display property is set to "none" Then I set the display property to "display" to get a drop-down listbox. The problem is the links in the list are all hilighted like they've been dragged over by a mouse. How do I prevent these links from highlighting? Hello, Is there any way I can prevent IE from displaying the "active X controls and script prevention message" when I load my web page into the browser. Firefox, Safari and Chrome, allow my scripts to run without displaying the message when the page is loaded into the respective browsers. Any tips would be really useful. Many thanks Nonye I've run into a glitch in my little calculator form. Apparently, in Safari, when you hit the enter key while the cursor is in an input field, it will attempt to submit the form. I don't want this to happen. Submitting serves no purpose in this, because all of the functionality is in the script on the page. I copied most of the HTML from an example, and noted that the form tag didn't contain an action= parameter. I tried adding this with the hopes that it would override Safari's default submit action. They do affect its behavior, but not in a way that does any good. First, I tried: action="" which didn't work Then, I tried: action="CalcRange()" This is a harmless function that normally runs on field change. It didn't work either. In every case Safari is determined to fire off a URL. No problems with MSIE or Firefox. Is there another way of using the action parameter to fix the problem, or do I have to attack this another way. Thanks. Code: <html><head><title></title> <script language="JavaScript"> var d = null; function PadCalc(ctrm,cvlo,cvhi,cstray,rc) { chp = cvhi+ctrm; clp = cvlo+ctrm; beta=(rc-1)*cstray; a=rc* clp- chp +beta; b= (rc-1)*clp*chp+beta*(clp + chp); c=beta*clp* chp; cser=(-b-Math.sqrt(b*b-4*a*c))/(a+a); return(cser); } function TrmCalc(cser,cvlo,cvhi,cstray,rc) { if (cser<0.00001) { ctrm=(cvhi+cstray-rc*(cvlo+cstray))/(rc-1); } else { cser2=cser*cser; k0=(1-rc)*cstray; k1=k0*cser2; k2=k0*cser+cser2; k3=k0*cser-rc*cser2; k4=k0+(1-rc)*cser; a=k4; b=k2+k3+k4*(cvlo+cvhi); c=k1+k2*cvhi+k3*cvlo+k4*cvlo*cvhi; ctrm=(-b-Math.sqrt(b*b-4*a*c))/(a+a); } return(ctrm); } function setCellTxt(id,tx,clr){ cell=document.getElementById(id); cell.innerHTML=tx; cell.style.color=clr; } function CalcAll() { setCellTxt("ex_cpar","***","#FF0000"); setCellTxt("ex_cser","***","#FF0000"); setCellTxt("ex_L","***","#FF0000"); flo = parseFloat(d.ef_flo.value); fhi = parseFloat(d.ef_fhi.value); cvlo = parseFloat(d.ef_cvlo.value); cvhi = parseFloat(d.ef_cvhi.value); cstray = parseFloat("0".concat(d.ef_cstray.value)); KVal = parseFloat(d.ef_KVal.value); spi = 500000.0/Math.PI; rf=fhi/flo; rc=rf*rf; switch(d.mknown.selectedIndex){ case 0: // For Given inductor L = KVal; w=(spi/flo) chppp = w*w/L; w=(spi/fhi) clppp = w*w/L; alpha = cstray-chppp; beta = cstray-clppp; k1 = cvhi-chppp-cvlo+clppp; k2 = alpha - beta; k3 = alpha*cvhi - beta*cvlo; k4 = alpha*cvhi; k5 = cvhi + alpha; a = -k2/k1; b = alpha-(k3+k2*k5)/k1; c = k4-(k3*k5)/k1; ctrm = (-b+Math.sqrt(b*b-4*a*c))/(a+a); cser = -(k2*ctrm+k3)/k1; if (cser>100*cvhi) cser=0; // End of given L calc break; case 1: // For Given Padder cser=KVal; if (cser<.00001) { cpinv=0; } else { cpinv=1/cser; } ctrm=TrmCalc(cser,cvlo,cvhi,cstray,rc); chp=cvhi+ctrm; chppp=1/(1/chp+cpinv)+cstray; w=spi/flo; L=w*w/chppp; break; case 2: // For Given Trimmer ctrm=KVal; cser=PadCalc(ctrm,cvlo,cvhi,cstray,rc); chppp=chp*cser/(chp+cser)+cstray; if (cser>100*cvhi) cser=0; w=spi/flo; L=w*w/chppp break; } badVal=false; if (isNaN(ctrm) || ctrm<0) badVal=True; if (isNaN(cser) || cser <0) badVal=True; if (isNaN(L) || L<0) badVal=True; if (!badVal) { setCellTxt("ex_cpar",ctrm.toFixed(2),"#000080"); setCellTxt("ex_cser",cser.toFixed(2),"#000080"); setCellTxt("ex_L",L.toFixed(2),"#000080"); } } function CalcRange() { flo = parseFloat(d.ef_flo.value); fhi = parseFloat(d.ef_fhi.value); cvlo = parseFloat(d.ef_cvlo.value); cvhi = parseFloat(d.ef_cvhi.value); cstray = parseFloat("0".concat(d.ef_cstray.value)); if (flo>0 && fhi>0 && cvlo>0 && cvhi>0) { spi = 500000.0/Math.PI; rf=fhi/flo; rc=rf*rf; csmin=PadCalc(0,cvlo,cvhi,cstray,rc); ctmax=TrmCalc(0,cvlo,cvhi,cstray,rc); w=spi/flo chppp=cvhi*csmin/(cvhi+csmin)+cstray; Lmax=w*w/chppp; chppp=cvhi+ctrm+cstray; Lmin=w*w/chppp; //Reset exact calc outputs after input parameter change /* setCellTxt("ex_cpar","","#000080"); setCellTxt("ex_cser","","#000080"); setCellTxt("ex_L","","#000080"); */ if (Lmin<0 || Lmax<0 || ctmax<0 || csmin<0) { setCellTxt("rTrm","***","#FF0000"); setCellTxt("rPad","***","#FF0000"); setCellTxt("rInd","***","#FF0000"); } else { setCellTxt("rTrm","0 ... ".concat(ctmax.toFixed(2)),"#000080"); setCellTxt("rPad",">= ".concat(csmin.toFixed(2)," (if present)"),"#000080"); setCellTxt("rInd","".concat(Lmin.toFixed(2)," ... ",Lmax.toFixed(2)),"#000080"); } } } function kvChange() { descriptions = Array ("Enter Inductance Value (µH):","Enter Series Capacitance Value (pF):","Enter Parallel Capacitance Value: (pF)"); setCellTxt("KVdescription",descriptions[d.mknown.selectedIndex],"#000080"); setCellTxt("ex_cpar","","#000080"); setCellTxt("ex_cser","","#000080"); setCellTxt("ex_L","","#000080"); } </script> </head> <body onload="d = document.forms[0];"> <center> <h2>Bandspread Calculator</h2> </center> <form > <table style="width: 692px; height: 400px;" align="center" border="0"> <tbody> <tr> <td align="center" colspan=2"><B>Input Parameters:</B></td> </tr> <tr> <td align="right">Lowest Frequency (kHz):</td> <td><input name="ef_flo" onchange="CalcRange()" size="18"> </td> </tr> <tr> <td align="right">Highest Frequency (kHz):</td> <td><input name="ef_fhi" onchange="CalcRange()" size="18"> </td> </tr> <tr> <td align="right">Tuning Capacitor <I>C<sub>V</sub></I> Minimum Capacitance (pF):</td> <td><input name="ef_cvlo" onchange="CalcRange()" size="18"> </td> </tr> <tr> <td align="right">Tuning Capacitor <I>C<sub>V</sub></I> Maximum Capacitance (pF):</td> <td><input name="ef_cvhi" onchange="CalcRange()" size="18"> </td> </tr> <tr> <td align="right">Stray Capacitance <I>C<sub>S</sub></I> (pF):</td> <td><input name="ef_cstray" onchange="CalcRange()" size="18"> </td> </tr> <tr> <td align="center" colspan=2"><HR></td> </tr> <tr> <td align="center" colspan=2"><B>Allowable Component Ranges:</B></td> </tr> <tr> <td align="right">Trimmer Capacitor <I>C<sub>T</sub></I> (pF): </td> <td align="left" id="rTrm"><font color="#FF0000">***</font></td> </tr> <tr> <td align="right">Padder Capacitor <I>C<sub>P</sub></I> (pF): </td> <td align="left" id="rPad" ><font color="#FF0000">***</font></td> </tr> <tr> <td align="right">Inductor (µH): </td> <td align="left" id="rInd"><font color="#FF0000">***</font></td> </tr> <tr> <td align="center" colspan=2"><HR></td> </tr> <tr> <td align="center" colspan=2"><B>Exact Value Calculation:</B></td> </tr> <tr> <td align="right">Choose the Known Component:</td> <td> <select name="mknown" onchange="kvChange()" size="1"> <option selected="selected">Inductor</option> <option>Padder Capacitor (Series)</option> <option>Trimmer Capacitor (Parallel)</option> </select> </td> </tr> <tr> <td id="KVdescription" align="right">Enter the Known Component Value:</td> <td><input name="ef_KVal" size="18"></td> </tr> <tr> <td align="right">Click to Calculate the Unknown Components:</td> <td><input type="button" value="Calculate" onclick="CalcAll()"> </td> </tr> <tr> <td align="right">Trimmer Capacitor <I>C<sub>T</sub></I> (pF): </td> <td id="ex_cpar" > </td> </tr> <tr> <td align="right">Padder Capacitor <I>C<sub>P</sub></I> (pF): </td> <td id="ex_cser"> </td> </tr> <tr> <td align="right">Inductor (µH): </td> <td id="ex_L"> </td> </tr> </tbody> </table> </form> </body></html> Edit: I should also add that my web page is made using Apple's iWeb software, and it stores the above code in a separate file, and then uses the following iframe code to load it: Code: <iframe id="widget1-frame" src=".//BandspreadCalc_files/widget1_markup.html" frameborder="0" style="width: 100%; height: 100%;" scrolling="no" marginheight="0" marginwidth="0" allowTransparency="true"></iframe> So, when Safari submits the form, the result is that it loads a page containing only the widget1_markup.html code, and not the parent page. Either way, it's annoying, because any data that the user has entered in a field will be erased. Please, I need a code that is capable of preventing SEOQuake from loading on my websites, even if a user has installed the plug-in. For example, Google, Yahoo and Bing implements such feature. I just don't want it to load whenever anybody visits my sites. Hello. I have what I think is a simple request, but I'm not quite sure how to go about it. I hope you can help me! Problem: I am building an online store and need to restrict checkout unless a customer has bought at least $20 worth of items. If they have >$20, they can check out. If they have <$20, they should get an error when they click the checkout button that explains that there is a $20 minimum. I don't want them to be able to checkout, so maybe I also need to disable the button or hide it? Here are the two elements in my HTML: The total price div: Code: <div id="totalprice">{tag_productgrandtotal}</div> The checkout button: Code: {tag_buybutton,<img alt="" src="/CatalystImages/shop_checkout.png" />} Here is what I've tried to put together with my bare minimum knowledge of Javascript: Code: <body onload="checkOut()"> <script type="text/javascript"> function checkOut() { var tp = document.getElementById('totalprice').innerHTML; tp = tp.replace(/[^0-9$\.]/g,""); // strip anything except numbers decimals and $ sign if (tp < "$20.00") { ???????????????? } else { ????????????????? } } </script> I'm not sure the top part is correct, and where I've put "?????" I have no idea what to do to deactivate the checkout button and produce the error message. Thank you SO much for any help you can provide. I was curious if there is a method to keep a single input from submitting a form. I have an input into which I'm building a drop down search feature, however, I'd like it so when the user presses return there, instead of submitting the form, it runs an AJAX POST instead. I am currently using keyUp to recognize the button press, but its still submitting the form its attached to. Obviously, I'd like that not to happen. I am using an e-commerce solution to run my web business. The checkout portion of the website is COMPLETELY closed off to me and I can't access the files. What I need: A javascript example / solution that will prevent someone from submitting a form without first filling in a field. What I currently have is a series of radio buttons built into the checkout process. It displays 20 options and the customer has to choose which one of the twenty options applies to them. Each customer only has 2 valid options to choose from based on their zip code, but currently the other zip code shipping options are listed as well. I have built a javascript that works great hiding all of the shipping options, taking data from the customer, and then only showing the correct shipping option. The problem is, if the customer doesn't fill this out, then they can just hit submit and pay the default shipping option without ever seeing that they didn't choose the correct zip code. What can I do to prevent them from submitting the form? The submit form is a button and there are 6 other buttons and none of them have any identifying factors. Hello all, Please I need help, I have a php form with different fileds. I have a field called description. The description field should only contains pure text, no numbers, but my users are entering phone numbers and email addresses into this field despite to the fact that there is already dedicated fileds for email and phone. What I want is a javascript funtion or php function that will automatically delete the numbers or @ from the field or prevent entering numbers and @ signs on this particular field. Many thanks in advance for your help. |