Go Back   Forums > Community Chatterbox > Tech Corner > Programming
Memberlist Forum Rules Today's Posts
Search Forums:
Click here to use Advanced Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 17-05-2011, 10:51 AM   #1
wackypanda
Abandonia nerd

 
Join Date: Jan 2011
Location: ,
Posts: 51
Default Javascript form validation

The noob has returned.

Generally, if I want to do form validation I use the following format:

Code:
function validateForm(myForm)
{
if (failure conditions)
  {
  show error message;
  return false;
  }
return true;
}

<form onsubmit="return validateForm(this);"></form>
However, someone once told me it should be done like this:

Code:
function validateForm(myForm)
{
if (failure conditions)
  {
  show error message;
  }
myForm.submit();
}

<form onsubmit="validateForm(this); return false;"></form>
I don't quite get the logic behind the second one. It looks like it forces the user to turn on Javascript to submit the form. That gives me bad vibes.

What are your thoughts?
wackypanda is offline                         Send a private message to wackypanda
Reply With Quote
 


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript help? Maxor127 Programming 1 08-10-2009 06:30 AM
Something weird with JavaScript The Fifth Horseman Programming 2 15-07-2009 08:08 PM
Javascript And Firefox Abi79 Tech Corner 3 09-04-2006 05:53 AM


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump
 


The current time is 02:08 PM (GMT)

 
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.