Home arrow JavaScript arrow Page 4 - Form Validation with JavaScript

Rock On - JavaScript

javascriptForm validation can help to reduce the amount of bad data that gets saved to your database. In this article, find out how you can write a simple JavaScript form validator for basic client-side validation, and learn a little bit about JavaScript OOP in the process as well.

TABLE OF CONTENTS:
  1. Form Validation with JavaScript
  2. Check Point
  3. Object Lessons
  4. Rock On
  5. Hammer Time
  6. How Things Work
  7. A Little Space
  8. Expressing Yourself
  9. Under Construction
  10. A Quick Snack
By: Nariman K, (c) Melonfire
Rating: starstarstarstarstar / 464
December 01, 2003

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
You've probably already used JavaScript objects before. For example, the code...

<script language="JavaScript">
a = new Image();
</script>


... creates a new instance of the Image object, while...

<script language="JavaScript">
x = new Date();
</script>


... creates a new instance of the Date object.

JavaScript comes with numerous built-in objects, each with pre-defined methods and properties. But what if you want to roll your own?

Well, it isn't very difficult. As a matter of fact, it's almost identical to writing a JavaScript function.

<script language="JavaScript">
// object constructor
function Band() 
{
...
}
</script>


You can create an instance of the Band object like this:

<script language="JavaScript">
// object instance
obj = new Band();
</script>


Note the all-important "new" keyword - this is how JavaScript knows that you're trying to create an instance of an object, rather than merely running a function.

The code above creates an instance named "obj" of the object Band. You can verify that it is indeed an object by popping up an alert().

<script language="JavaScript">
obj = new Band();
alert(obj);
</script>




 
 
>>> More JavaScript Articles          >>> More By Nariman K, (c) Melonfire
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

JAVASCRIPT ARTICLES

- Javascript for Beginners: An Introduction
- Introduction to JavaScript
- Adding Elements to a Tree with TreeView jQue...
- Using the Persist Argument in a TreeView jQu...
- Using Unique and Toggle in a TreeView jQuery...
- Using Event Delegation for Mouseover Events ...
- Using the Animate Option in a Treeview jQuer...
- Using HTML Lists with Event Delegation in Ja...
- Opened and Closed Branches on a TreeView jQu...
- Mouseover Events and Event Delegation in Jav...
- Creating a TreeView JQuery Hierarchical Navi...
- Event Delegation in JavaScript
- A Look at the New YUI Carousel Control
- Working with Draggable Elements and Transpar...
- Displaying Pinned Handles with Resizable Con...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: