Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML
 
 
Hot Web Programming Job

 

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML


 

Search Host

Monthly Fee($)
Disk Space (MB)
Register With us for Newsletter!
Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Have tutorials?
Add your tutorial to our Java Resource and get tons of hits.

We offer free hosting for your tutorials. and exposure for thousands of readers. drop a mail
roseindia_net@yahoo.com
 
   

Tutorials

Java Server Pages

JAXB

Java Beans

JDBC

MySQL

Java Servlets

Struts

Bioinformatics

Java Code Examples

Interview Questions

 
Join For Newsletter

Powered by groups.yahoo.com
Visit Group! Post Questions!

Web Promotion

Web Submission

Submit Sites

Manual Submission?

Web Promotion Guide

Hosting Companies

Web Hosting Guide

Web Hosting

Linux

Beginner Guide to Linux Server

Frameworks

Persistence Framework

Web Frameworks

Free EAI Tools

Web Servers

Aspect Oriented Programming

Free Proxy Servers

Softwares

Adware & Spyware Remover

Open Source Softwares

Form Validation using Regular Expressions is JavaScript

                         

In this article you learn the basics of JavaScript and create your first JavaScript program.

What is JavaScript validation using Regular Expressions?
The JavaScript Validating user input is the bane of every software developer’s existence. The developing cross-browser web applications this task becomes even less enjoyable due to the lack of useful intrinsic validation functions in JavaScript. JavaScript 1.2 has incorporated regular expressions. This article I will present a brief tutorial on the basics of regular expressions and then give some examples of how they can be used to simplify data validation. A demonstration page and code library of common validation functions has been included to supplement the examples in the article. 
 

Regular Expression:
JavaScript regular Expression is the very powerful tool and performing for the patterns  matches. the PERL programmers and UNIX shell programmers have enjoyed the benefits of regular expressions for years. Once you  are master the pattern language, most validation tasks become trivial. if you perform complex tasks that once required lengthy procedures with just a few lines of code using regular expressions. 
The regular Expression two intrinsic objects associated with program. 
The RegExp object and 
The Regular Expression object.
The RegExp object is the parent in regular expression object. RegExp has a constructor function that is instantiates of the Regular Expression object much like the Date object instantiates an new date.

Example:

                         Var RegularExpression = new RegExp("pattern", ["switch"])

The JavaScript has been creating alternet  syntax for Regular Expression objects. There are implicitly calls the RegExp constructor function. The syntax for the follows: 
 

                        var RegularExpression =  /pattern/[switch]

Using JavaScript Validation
The JavaScript validation  offered the way if the field contained certain characters using the index Of() method. The character was found, the position of the character was returned as a number.

Example:

                            var x = "my program's contents"; 
                            var y = x.indexOf("my")
;

The JavaScript validation using indexOf(), you would be required to write several lines of code, each using the indexOf() to look for all the characters you didn't want to find. If an illegal character is found, an alert box could be flashed asking the user to re-enter their information. The  functions use JavaScript 1.0 functionality to examine the text field containing regular text or a text field containing an email address. By passing the contents of the form to the isReady() function using the on Submit event handler, the information is validated before being sent to the server. validation function is the returns true, the ACTION attribute of the form is run. 

 Example:

<html>
<head>
<script language="JavaScript">
 function isEmail(string
{
 if (!string) return false; var iChars = "*|,\":<>[]{}`\';()&$#%";
 for (var i = 0; i < string.length; i++) 
{
 if (iChars.indexOf(string.charAt(i)) != -1) return false; 

return true;
 } 
</script>
</head>
</html>

Using Javascript Regular Expression:
The JavaScript 1.2 the way through the power of regular expressions. These expressions, which are offer the same functionality as regular expressions taken from Perl is a very popular scripting language, add the ability to parse form field input in ways that were simply not possible before. The Netscape Navigator 4.0x and Internet Explorer 4, illuminate the power associated with the new additions. It is JavaScript contains a number of new constructors and methods the allow a programmer to string of text using regular expressions. The first thing must be before you can begin parsing a string is to determine exactly regular expression will be. There are two way follows:-
The first is to specify it by hand using normal syntax, and 
The second is to use the new RegExp() constructor

Example:

                                                      pattern = /:+/; 
                                                      pattern = new RegExp(":+"); 

The JavaScript  replace() method allows a programmer to replace a found match with another string. that takes two arguments, one being the regular expression if you want to searched for, and the other being the replacement text you want substituted.

Example:

                      var c = "my first program JavaScript"; 
                      var i = c.replace(/javascript/, "JavaScript"); 

 

                         

Useful Links
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.