javascript

Recommendation for javascript form validation library

Any recommendations for a javascript form validation library. I could try and roll my own (but I'm not very good at javascript). Needs to support checking for required fields, and preferably regexp validation of fields. ...

The best way of checking for -moz-border-radius support

I wanted some of those spiffy rounded corners for a web project that I'm currently working on. I thought I'd try to accomplish it using javascript and not CSS in an effort to keep the requests for image files to a minimum (yes, I know that it's possible to combine all required rounded corner shapes into one image) and I also wanted to b...

Validate numbers in JavaScript - IsNumeric()

What's the cleanest, most effective way to validate decimal numbers in JavaScript? Bonus points for: Clarity. Solution should be clean and simple. Cross-platform. Test cases: 1. IsNumeric('-1') => true 2. IsNumeric('-1.5') => true 3. IsNumeric('0') => true 4. IsNumeric('0.42') => true 5. Isnumeric('.42') => true 6. IsNUmeric(...

What did I do wrong here? [Javascript Regex]

So I am writing a registration form and I need the display name to be only numbers, letters and underscores. Have a look at my code and tell me what I'm doing wrong. <form method="post" action="/" onsubmit="return check_form()"> <input type="text" id="display-name" name="display-name" maxlength="255" /> <input type="submit" /> ...

How to find keys of a hash?

I know in javascript Objects double as hashes but i have been unable to find a built in function to get the keys var h = {a:'b',c:'d'}; I want something like var k = h.keys() ; // k = ['a','c']; It is simple to write a function myself to iterate over the items and add the keys to an array that I return, but is there a standard cl...

Javascript Beautifier

I am looking for a code beautifier that supports javascript and works on both windows and linux and can be used in batch scripts. Any recommendations? ...

Javascript Load Order

Hey I am working with both amq.js (ActiveMQ) and Google Maps. I load my scripts in this order <head> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <title>AMQ & Maps Demo</title> <!-- Stylesheet --> <link rel="stylesheet" type="text/css" href="style.css"></link> <!-- Google APIs --> <scrip...

Best way to fix CSS/JS drop-down problem in IE7 when page includes Google Map

I have a page using < ul > lists for navigation (Javascript changes the styling to display or not on mouseover). This is working fine for me except in IE6 and IE7 when I have a Google Map on the page. In this case the drop-down simply does not work. However, the page continues to work in FireFox 2. I have done a little bit of research...

Are there reasons not to use JSONP for AJA~X requests?

If you're building an AJA~Xy app, are there any downsides to using JSONP requests/responses even if you're not planning on any cross-domain requests? The only thing I can think of is that there are a couple extra bytes for the callback wrapper... Edit: I found this which also suggests security and error handling as potential problems....

Code to ask yes/no question in javascript

I could only find the function confirm() that gives OK/Cancel buttons. Is there any way to give Yes/No buttons? ...

Click an image, get coordinates

I know it can be done and I even have a vague idea of how to do it but it stops at being vague. I have a standard HTML image tag with an image in it, 100 by 100 pixels in size. I want people to be able to click the image and for that to pass the X and Y that they click into a function. The coordinates need to be relative to the image t...

Best way to keep an ordered list of windows (from most-recently created to oldest)?

A friend had phoned me the other day asking for the best way to manage a list of windows (keeping them in order) so he can promote the next window to the top-level when the current top-level window is closed. This is for a web application, so we're using jQuery Javascript. We'd talked through a few simplistic solutions, such as using an...

JavaScript Profiler in IE

Does anyone know a tool for Profiling JavaScript in IE? List available: IE8 (Internet Explorer 8 only) JavaScript Profiler YUI! ...

Executing JavaScript from Flex: Is this javascript function dangerous?

I have a flex application that needs the ability to generate and execute JavaScript. When I say this, I mean I need to execute raw JavaScript that I create in my Flex application (not just an existing JavaScript method) I am currently doing this by exposing the following JavaScript method: function doScript(js){ eval(js);} I can then...

How do you dynamically load a javascript file? (Think C's #include)

How can you reliably and dynamically load a javascript file? This will can be used to implement a module or component that when 'initialized' the component will dynamically load all needed javascript library scripts on demand. The client that uses the component isn't required to load all the library script files (and manually insert t...

Adobe AIR: Handling JSON objects from server

I have a script that retrieves objects from a remote server through an Ajax call. The server returns objects in JSON notation. However, in Adobe AIR, there is a restriction on using eval() for security reasons. So I'm able to get replies from the remote server, but can't turn them back into Javascript objects. Is there any workaround fo...

XmlHttpRequest return values

For an application I'm building in my spare time I am looking for (arguably) the correct way to return data from an XmlHttpRequest. Options I see are: Plain HTML. Let the request format the data and return it in a usable format. Advantage: easy to consume by the calling page. Disadvantage: Very rigid, stuck with a fixed layout. XML. L...

Adding Inline Search function to web page

Is it possible to embed an inline search box into a web page which provides similar functionality to the IE7Pro Inline Search or similar plugins for Firefox/Safari? ...

Is there some way to show HTML content inside Flash?

I want to show HTML content inside FLASH. Is there some way to do this? I am talking about full blown HTML (with JavaScript if possible) ...

How to provide namespaces in JavaScript with instanced objects

I've got a JavaScript "object", built this way: function foo() { this.length = 0; } foo.prototype.getLength = function() { return this.length; } ... I know how to emulate namespaces with singleton JavaScript objects, but what is the best way to "namepace" an object such as that above that will intanced? I know that several...