|
![]() |
#1 | ||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2011
Location: ,
Posts: 51
|
![]() 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> Code:
function validateForm(myForm) { if (failure conditions) { show error message; } myForm.submit(); } <form onsubmit="validateForm(this); return false;"></form> What are your thoughts? |
||
![]() ![]() |
|
![]() |
#2 | ||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Dec 2010
Location: ,
Posts: 202
|
![]() There are really too many variables when considering the creation and validation of a form. If you consider javascript to be a bad thing, is your form secured without it? Is the form client-side or server-side only, or a mix? Is the code going to include warnings that javascript is disabled (meaning required by the form)? Is the code in the first example as compact as it should be, or are you questioning the difference between the two based on structure and content vs. format for end result?
In order to answer the question to yourself, you would really need to define the parameters for the environment/users the form would be targeted for. Hmm... someone is trying to make you think. This must be a school lesson.
__________________
I can ride my bike with no handlebars |
||
![]() ![]() |
|
![]() |
#3 | ||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2011
Location: ,
Posts: 51
|
![]() Quote:
- If anything is being done server-side, server-side validation is inevitable (and therefore Javascript validation is not crucial). - With Javascript, less is more. I suppose the second could be used if the purpose of the form is such that Javascript has to be on anyway. It still doesn't seem like an ideal structure. Last edited by wackypanda; 19-05-2011 at 04:58 PM. |
||
![]() ![]() |
|
![]() |
#4 | ||
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Sep 2004
Location: Valleyfield, Canada
Posts: 4,892
|
![]() Anything that force me to turn JavaScript on a site I don't want to gives me bad vibes too...
|
||
![]() ![]() |
|
![]() |
#5 | ||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Dec 2010
Location: ,
Posts: 202
|
![]() Code:
function validateForm(myForm) { if (failure conditions) { show error message; return false; } } <form onsubmit="return validateForm(this);"></form> At least that's how I understand it.
__________________
I can ride my bike with no handlebars |
||
![]() ![]() |
|
![]() |
|
![]() |
||||
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 |
|
|
||
  |