background preloader

Javascript

Facebook Twitter

JavaScript Regular Expressions methods and usage. JavaScript Kit- RegExp (regular expression) object. Updated: June 27th, 2011 Regular expressions are a powerful tool for performing pattern matches in Strings in JavaScript. You can perform complex tasks that once required lengthy procedures with just a few lines of code using regular expressions. Regular expressions are implemented in JavaScript in two ways: Literal syntax: //match all 7 digit numbers var phonenumber= /\d{7}/ Dynamically, with the RegExp() constructor: //match all 7 digit numbers (note how "\d" is defined as "\\d") var phonenumber=new RegExp("\\d{7}", "g") A pattern defined inside RegExp() should be enclosed in quotes, with any special characters escaped to retain its meaning (ie: "\d" must be defined as "\\d").

Related Tutorials (highly recommended readings) Pattern flags (switches) Position Matching Literals The backslash (\) is also used when you wish to match a special character literally. Character Classes Repetition Alternation & Grouping Back references Regular Expression methods. Programmation JavaScript/Notation JSON.

Un livre de Wikilivres. La notation objet du langage Javascript JSON (JavaScript Object Notation en anglais) permet de déclarer des objets en donnant la valeur des membres. Cette notation concerne également les tableaux qui sont considérés comme des objets. Elle abrège la déclaration de données en permettant de donner toutes les valeurs d'un objet ou d'un tableau en une seule expression. Cette expression peut, par exemple, être passée en paramètre d'une fonction. Tableau[modifier | modifier le wikicode] Un tableau est en réalité une forme spéciale d'objet.

La syntaxe abrégée pour déclarer le contenu d'un tableau utilise une série de valeurs entre crochets : [ valeur, valeur... ] Où valeur est une expression dont le type peut être quelconque (entier, chaîne de caractères, tableau, objet, ...). Exemple : var fruits = [ "pomme", "orange", "pamplemousse" ]; Équivalent sans la notation : var fruits = new Array(); fruits[0] = "pomme"; fruits[1] = "orange"; fruits[2] = "pamplemousse"; Variante :

JavaScript UI Framework - Ample SDK. How to Submit a Form Using JavaScript. Generally, a form is submitted when the user presses a submit button. However, sometimes, you may need to submit the form programmatically using JavaScript. JavaScript provides the form object that contains the submit() method. Use the ‘id’ of the form to get the form object. For example, if the name of your form is ‘myform’, the JavaScript code for the submit call is: But, how to identify a form? Here is the code to submit a form when a hyperlink is clicked: Click the link below to see the code in action:JavaScript Form Submit Example 1 Make forms with custom Submit Button Use Simfatic Forms to visually design your HTML Forms.

Conducting Form Validations You can make your form validations very easy by using the Form Validator Script. The form validation script uses the onsubmit() event of the form to validate the input. See the example below: See the code in action! Using image for submitting the form Instead of the default gray submit button, you may like to use an image. Be Sociable, Share! Ctrl + Key Combination – Simple Jquery Plugin | Ganesh. In a recent web application I was working on, I had a need for the “Ctrl + S” hotkey to save an entry to the database. Being a an avid jquery fan, I immediately searched the plugin repository for any plugin that fits the bill. I was not very surprised to find a very comprehensive jshotkeys plugin.

It was feature rich and addressed all the requirements for hotkeys in a jquery powered application and obviously my requirement was fulfilled as well. But the basic issue (and advantage too) with any plugin is that it is written for a wide range of audience. . $.ctrl = function(key, callback, args) { var isCtrl = false; $(document).keydown(function(e) { if(! This is how it works: 1. In the code given below, when the user presses the “Ctrl + S” key combination, the anonymous callback function passed in as the second parameter is called. $.ctrl('S', function() { alert("Saved");}); $.ctrl('D', function(s) { alert(s);}, ["Control D pressed"]); Thats it. What do you think? This is how it works: 1. Regular Expressions: Methods - Doc JavaScript. JavaScript Regular Expressions Regular Expression (and String) Methods In this section we'll discuss methods that are related to regular expressions. Some are invoked as a method of a regular expression, whereas others are called as a string's method. compile compile() is invoked as a method of a regular expression.

Its syntax is: regexp.compile("PATTERN", ["g"|"i"|"gi"]) regexp is the name of a regular expression.PATTERN is the text of the regular expression. Use the compile() method with a regular expression that was created with the constructor function (not the literal notation). The compile() method can also be used to change a regular expression during execution: var reg = new RegExp("Bart", "i"); // reg matches "Bart" here reg.compile("Lisa", "i") // reg doesn't match "Bart" here You can also use this method to modify a regular expression's modifier: var reg = new RegExp("bart", "i"); // reg matches "Bart" here reg.compile("bart") // reg doesn't match "Bart" here exec regexp.exec(str) test.

Javascript / escape(), encodeURI(), encodeURIComponent() The best resource for PHP tutorials, templates, PHP manuals, content management systems, scripts, classes and more. Introduction: Although the concept isn't entirely new, XMLHttpRequest technology is implimented on more sites now than ever. Compatibility is no longer an issue (IE, Mozilla and Opera all support it), and the benefits to using it are amazing. There are too many PHP programmers avoiding any work with JavaScript beyond simple form validation, and for good reason. It's difficult to keep several languages proficiently under your belt. But using the XMLHttpRequest object is not as hard as everybody thinks, and you don't need to buy and memorize another reference manual. Let's Get To It! Asynchronous JavaScript and XML, or AJAX is a method of sending and receiving data (usually XML) from a server-side application through javascript.

As PHP developers, it might seem tempting to avoid the use of Javascript and leave it to the dsigner. If you're working for a small or medium sized company interested in implementing AJAX solutions, you might end up responsible for figuring out how. Variables: PHP Input Filter (xss, filter, input filter, inputfilter) x5s - test encodings and character transformations to find XSS hotspots. Here's a quick tutorial to get you familiar with x5s and how to use it.

I'm assuming now that you have Fiddler and x5s installed. Configuration Open Fiddler, go to the x5s tab, click Enable. Type in the Preamble 'pqz'. Check the box to Enable Domain Name Targetting and add the domain 'nottrusted.com'. Be sure to enable the two check boxes for 'Applies to' requests and responses.

You're almost set up! Test Case Configuration Now move to the 'Test Case Configuration' tab, where you'll find all of the test cases x5s will send as character probes. We'll pick one or more from each category to get started. U+FF1C FULLWIDTH LESS-THAN SIGN from the Transformable test typeU+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE from the Transformable test typeU+0022 QUOTATION MARK from the Traditional test typeU+003E GREATER-THAN SIGN > from the Overlong test typeWe're all set and ready for testing! Interpreting the Results If you double-click this row you'll be taken to Fiddler's session inspector.

How to capture enter key pressed in a form (JavaScript) - Barattalo.