HighDots Forums  

form validation oop

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss form validation oop in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
krraleigh
 
Posts: n/a

Default form validation oop - 01-08-2009 , 08:48 PM






I would like to roll my own validation script in oop.
I have read a few articles on it but I haven't found anything
that works when the user leaves the field. Ergo -> onblur = my function()

Before I begin this does anyone have any reservations on using onblur
for form validation?

I know that using onblur() has it's problems, In particular the user might
skip one of the fields entirely.

So I need to also check the entire form when the user clicks submit.
I saw an example of all of this a year or so ago, but I didn't have to time
to play with it. And I can't seem to find it.

After the client side script runs I will also have a back up on the server
side.
Is running both a problem?

Any advise or good links that you might have?
Best practices etc...

Thank You
Kevin


Reply With Quote
  #2  
Old   
Norman Peelman
 
Posts: n/a

Default Re: form validation oop - 01-09-2009 , 05:55 AM






krraleigh wrote:
Quote:
I would like to roll my own validation script in oop.
I have read a few articles on it but I haven't found anything
that works when the user leaves the field. Ergo -> onblur = my function()

Before I begin this does anyone have any reservations on using onblur
for form validation?

I know that using onblur() has it's problems, In particular the user might
skip one of the fields entirely.

A user may not fill a form out in order, either.

Quote:
So I need to also check the entire form when the user clicks submit.
I saw an example of all of this a year or so ago, but I didn't have to time
to play with it. And I can't seem to find it.

After the client side script runs I will also have a back up on the
server side.
Is running both a problem?

Any advise or good links that you might have?
Best practices etc...

Thank You
Kevin
--
Norman
Registered Linux user #461062


Reply With Quote
  #3  
Old   
alex
 
Posts: n/a

Default Re: form validation oop - 01-12-2009 , 03:02 AM



krraleigh wrote:
Quote:
I would like to roll my own validation script in oop.
I have read a few articles on it but I haven't found anything
that works when the user leaves the field. Ergo -> onblur = my function()

Before I begin this does anyone have any reservations on using onblur
for form validation?

I know that using onblur() has it's problems, In particular the user might
skip one of the fields entirely.

So I need to also check the entire form when the user clicks submit.
I saw an example of all of this a year or so ago, but I didn't have to time
to play with it. And I can't seem to find it.

After the client side script runs I will also have a back up on the
server side.
Is running both a problem?

Any advise or good links that you might have?
Best practices etc...

Thank You
Kevin
It's OK to use onblur (or onchange) to validate the contents of a single
field. There are some JavaScript libraries out there that do just
that, and let you specify regular expressions to do the validation.

However, you should also validate the entire form when it is submitted
(probably using the same validation library). Even then, you cannot
assume that the information in the form is valid, because the JavaScript
validation may have been skipped (no JavaScript, JavaScript altered) -
you should definitely perform the validation on the server as well.

Remember that validation using JavaScript is nice (immediate feedback
for the user, possibly field coloring or other visual effects), but that
you must never rely on it alone.

Rolling your own JavaScript validation library is not difficult, but
perhaps you want to check out:

* http://www.jsvalidate.com/
* http://yav.sourceforge.net/

HTH,
alex


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.