Today, programmers can’t do without regular expressions, and it’s a good idea to familiarize yourself with their options in JavaScript as well. The article contains a test of your knowledge.
The examples given in the article taiwan phone number data were updated on 3/16/2012.
There are two ways to create a regular expression in JavaScript:
The first way is simpler, but does not allow using a variable inside the RE. RE evaluation can be influenced by adding modifiers. E.g. modifier i
makes it case insensitive.
Occurrence testing
The test() method of the RegExp object is ideal for finding out whether a substring corresponding to a given RE is found in a certain string . Its argument is the string to be tested. Returns a boolean value . The first base on your analytics example, the body of the return function called when the form is submitted, is used to check the correct form of the email address.
AJAX and Cross-site Scripting
The first thing that comes to mind for most web programmers is the use of the AJAX technique, more precisely the internal HTTP client that is available in JavaScript. Unfortunately, wheat will not bloom for cg leads us here, because most browsers quite actively prevent the so-called cross-site scripting . An AJAX request cannot be directed to a domain other than the one from which the displayed page originates. More precisely, it is necessary that the domain name, communication protocol and port number match.