javascript

[jQuery] Validate select box

I'm using the jQuery plugin Validation to validate a form. I have a select list looking like this: <select id="select"> <option value="">Choose an option</option> <option value="option1">Option1</option> <option value="option2">Option2</option> <option value="option3">Option3</option> </select> Now, I want to make sure that the user s...

JavaScript factory with optional arguments

The problem is that I need to create a new instance of the passed class Is there a way to rewrite this function, so it could accept any number of arguments? function createInstance(ofClass, arg1, arg2, arg3, ..., argN){ return new ofClass(arg1, arg2, arg3, ..., argN); } This function should create an instance of the passed class. E...

jQuery Screen Resolution Height Adjustment

In order to better balance out a page I am working on I would like to find a way to increase the top margin of a DIV depending on the screen resolution. What is my best way to set these dimensions with jQuery or Javascript? Thanks in advance. Brad ...

jQuery - Disable Click until all chained animations are complete.

Question The solution below is intended to slide down the groupDiv displaying div1 and enough space for div2 to slide in. It's all achieved by chaining the animations on the #Link.Click() element. It seems to bug out, though, when the link is clicked rapidly. Is there a way to prevent this? By perhaps disabling the Click function until...

How to dynamically register to jquery custom events?

Hello all, I have built a dom object Engine that has private/public fields/methods that I have simplified below: function Engine(args){ this.display = args.display; this.getDisplay = function(){return this.display;} this.alertMsg = function(msg){ console.log(this.display); alert(msg); } } What I would like to...

multithreading And Subscribe/Publish approach in javascript

Hi, I understand that there is no multithreading support in javascript. And i wanted some expert advice on the below scenario.. My requirement is to perform a AJAX call and upon successful completetion, i want to trigger set of events (to update the different parts of UI parallely) I am planned to use Subscribe/Publish pattern, is i...

Using Selenium to Test jQuery element data()?

Is it possible to use selenium to test whether a jQuery data() is set on an element? In my app, the user enters information about several orders. Each order gets appended to an overview table so they can see their progress as they're going. In addition to the visible order information, we store some additional information that we need...

Javascript validation and posting at the same time.

function echeck(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1){ alert("Invalid E-mail ID") return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ alert("Invalid E-mail ID") return false } if (str.ind...

Looping over all window [global] variables in javascript. IE compatible?

I'm trying to loop over all JavaScript variables to find ones that match a certain regex. The function works fine in every browser but IE, it appears that the for loop does not read in every global variable even though it's there. I can access the variable directly using window.variable but it does not appear in the loop. var w = wind...

Testing JavaScript code without recreating markup?

I want to test the JavaScript code in our web app. We are using the jQuery library and .Net MVC. I've looked at these answers, and jqUnit looked nice, so I tried it, just to realize that I'll have to pretty much recreate all markup for every page I want to test. Am I missing something? Are there any alternative approaches for testing J...

checking if number entered is a digit in jquery

I have a simple textbox in which users enter number. Does jQuery have a isDigit function that will allow me to show an alert box if users enter something other than digits? the field can have decimal points as well. ...

Javascript does not support positive lookbehind

I have the following regular expression in .Net (?<=Visitors.{0,100}?"value">)[0-9,]+(?=) and the following text <div class="text">Visitors</div> <div class="value">14,000,000</div> <div class="text">VisitorsFromItaly</div> <div class="value">15,200</div> I specify in the regex either "Visitors" or "VisitorsFromItaly" and I get the...

Lightbox using an area map in Internet Explorer

I am trying to use Lightbox with an area map. I have gotten it to work fine with Firefox, but in Internet Explorer, it simply opens a new window. I tried using Slimbox, but it doesn't seem to support area maps at all. Suggestions? Here is the HTML code: <div align="center"><img src="images/background-temporary.jpg" width="667" height="...

Can the mask of a RadMaskedTextBox be changed via javascript?

I have a dropdown and a RadMaskedTextBox on a form. I want the mask applied to the RadMaskedTextBox to be determined by the selected value of the dropdown. Is there any way to do so via javascript? I know I could do a simple postback, but I would prefer not to. Thanks! ...

Changing node id by replacing the node

I am trying to polish off a nav menu by having a script that fetches the current page name (via $_SERVER["PHP_SELF"]) and then in JavaScript finds the relevant name (i.e. from /contact.php finds just contact) and searches for an element with that id (my list items have ids that match their target). Now I want to swap the id of the eleme...

Do any prevalent Javascript frameworks provide a utility for pruning objects?

We're using jQuery on a less UI-intensive project whereas we have been using ExtJS on other projects. Regardless, I'm curious if any of the prevalent libraries such as ExtJS, jQuery, or others, provide a utility for "pruning" objects? By which I mean, deleting keys if they don't contain values. I've devised my own (naive) implementati...

Generating JSON Object

I'm trying to parse the rows in a table that I generate using javascript by adding items to a cart and then create a json object when the user hits save order of all the items and pass it to a php script using $.post in jQuery. The only trouble I'm having is understanding JSON objects and how to push more items onto the object. I get an...

Icefaces and javascript bridge

Hi all, I'm facing a problem with Icefaces and it's javascript bridge. I don't know what are the changes which made by this bridge after i made a changes in the server-side. For example: I have a ice:panelPopup component in my page with the visible attribute = "#{bean.customPopUp}". If i changed the "bean.customPopUp" to be "true" the p...

Fetching HTML into a <div> and overwrite content.

Hello everyone, I have a website with a top panel and a body part. The top panel can be toggled between hidden and shown. The body part should contain the actual content of the website. As I don't want to hard-code every single site, I would like to stay with the panel and only reload the content. This seems to can be done using AHA...

how to include javascript files in Google Gears Worker (no DOM access)

how does one include other .js files in the .js of a Worker. Every "include" solution for Javascript that I've found does it by loading into a tag, which is not an option for Workers since they don't have access to the DOM. I see from your 950087/include-javascript-file-inside-javascript-file that using Ajax and eval() will do it. I ca...