<<BACK HOME CNCPT TTRL JS | sf.net/projects/validateformjs | [ u | s | M | ? ] |
rqd dec eml int len mcr bss trm sif | All Concepts | |
frm txt pwd txa rdo sl1 chk slm | All Object Types |
validate_form.js
validate_form.js
is a comprehensive and easy-to-use solution for enforcing the most common requirements in html forms. Features a small client download, and fully-configurable user-error messages. Optional features--which are not downloaded until explicitely activated by you--include debugging output, and the new Permanent VF-Diagnostics toolbar.
Current version is 1.9b, as of Monday, July 05, 2004.
Table of Contents | ||
Section | Description | |
GO |
Concepts and Object Types | Documentation and interactive examples for every concept and object type |
GO |
Tutorial | Getting started with the basic concepts |
GO |
JavaScript Code | API for all public classes and functions |
GO |
![]() |
The official site for validate_form.js |
GO |
Installation | Installation and build instructions |
GO |
Attributes and Special String list | Every available attribute and special string |
GO |
Unit tests | Verification with code snippets |
GO |
Compression statistics | Detailed information on the compression process for every JavaScript file |
GO |
Appendix | Secondary documentation |
GO |
Copyright Notice | validate_form.js is released under the BSD License (with no advertising clause) |
...
Learning JavaScript: Want to learn some more about JavaScript? Check out the source code of these examples....
Companies who use validate_form.js
...
Known issue: Element names containing "[" and "]"...
Compression statistics for documentation-exclusive JavaScript....
The main build process (not contained in any download archive)....
The process that generates the JavaScript API....
Process that creates compression statistics for the main VF-classes....
Process that creates doc-exclusive compression statistics....
The process that generates the 'tryit' code, from the demo code displayed at the bottom of each tutorial page.It is expected that all element names only contain letters, digits and underscores. Also, you must ensure that no two non-radio/non-checkbox elements have the same name. Not following these rules may cause unpredictable behavior.
These naming requirements preclude the use of arrays within form element names. However, there is a workaround:
I've not verified this, although the concept seems to be a valid one. Anyone have experience with this? A truly working example would be helpful. Thanks.
<HTML><HEAD>
<SCRIPT LANGUAGE="JavaScript" SRC="../js_maxc/validate_form.js" TYPE="text/javascript"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
function isFormValid(f_orm) {
var sPrefix = ' --';
f_orm.your_name = f_orm.name[1];
f_orm.your_name.sMsgRequired = 'What is your name?';
var sErrors = getFormErrorMsgs(f_orm, sPrefix, 2);
if(sErrors != '') {
alert("ERRORS FOUND\n\n" + sErrors");
return false;
}
return true;
}
//-->
</SCRIPT>
</HEAD><BODY>
<FORM onSubmit="return isFormValid(this);">
<BR>What is your name? <INPUT TYPE="text" NAME="name[1]"><HIDDEN TYPE="text" NAME="your_name">
<P><INPUT TYPE="submit"></P>
</FORM>
</BODY></HTML>
![]()
|
This is a complete listing of validate_form.js
' attributes and special strings (~FOR_EXAMPLE~
). Special strings are put into the value of the 'sMsg*
' attribute, and are replaced with the value as described below. When the value is not avaliable, the special string itself is displayed.:
bsGlobalTrimSpaces
: If 'true', then trim spaces from the start and end of all string values.[txt/pwd/txa].bsTrimSpaces
: When [form].bsGlobalTrimSpaces
is not provided, this is how you trim the value of a single element.[txt/pwd/txa].bsDontTrimSpaces
: Overrides [form].bsGlobalTrimSpaces
for a single elementasGlobalBadSubStrs
: An array of strings considered illegal when any string value equals or contains any one.[txt/pwd/txa].bsNoBadSubStrs
: Overrides [form].asGlobalBadSubStrs
for a single element, declaring that no sub-strings are illegal for it.[txt/pwd/txa].asBadSubStrs
: Overrides [form].asGlobalBadSubStrs
for a single element, defining an element-specific list of illegal sub-strings. This may be used even when [form].asGlobalSubStrs
is not provided.[txt/pwd/txa].sMsgBadSubStr
: The user error message when an illegal sub-string equals, or is found in, a string value.~BSS_FOUND~
: Special strings for displaying the found-sub-string.~BSS_LIST~
: Special strings for displaying the entire list of bad sub-strings.text/password/textarea/radio/select-one/checkbox/select-multiple
)sMsgRequired
: Declares that the value for an element is required.text/password
:sMsgTxtDec
Must be a valid decimal, and within (the optional) range.~RANGE_MIN~
and ~RANGE_MAX~
: Special strings for dDecMin
/dDecMax
, when provided.dDecMin
: The minimum allowable value.dDecMax
: The maximum allowable value.sMsgTxtEmail
(non-numeric): Must be a valid email address.sMsgTxtInt
Must be a valid integer, and within (the optional) range.~RANGE_MIN~
and ~RANGE_MAX~
: Special strings for iIntMin
/iIntMax
, when provided.iIntMin
: The minimum allowable value.iIntMax
: The maximum allowable value.sMsgTxt*
: Create an SIFmt
object to enforce that values conform to a proper integer-string format, as required by things such as ssns, phone numbers, and zip codes.text/password/textarea
asBadSubStrs
: See [form].asGlobalBadSubStrs
.bsNoBadSubStrs
: See [form].asGlobalBadSubStrs
.sMsgBadSubStr
: See [form].asGlobalBadSubStrs
.sMsgBadLength
~RANGE_MIN~
and ~RANGE_MAX~
: Special strings for iMinLength
/iMaxLength
, when provided.~CURRLEN~
: Special string displaying the length of the string provided by the user.[txt/pwd/txa].iMinLength
: The minimum allowable length.[txt/pwd].MAXLENGTH
: The maximum allowable length (this is standard HTML).[txt/pwd/txa].iMaxLength
: The maximum allowable length.bsDontTrimSpaces
: See [form].bsGlobalTrimSpaces
.bsTrimSpaces
: See [form].bsGlobalTrimSpaces
.checkbox/select-multiple
sMsgMCRange
: Defines a range of how many multiple-choice responses are allowed to be selected.~OPTS_TOTAL~
: Special string for the total number of available options.~OPTS_CHOSEN~
: Special string for number of options chosen by the user.~RANGE_MIN~
, and ~RANGE_MAX~
: Special strings for iMCMin
/iMCMax
, when provided.iMCMin
: The minimum allowable choices.iMCMax
: The maximum allowable choices.validate_form.js
Here are a list of companies and individuals that use validate_form.js
in their real-world projects:
validate_form
library. It’s easy to use and the documentation is very complete."validate_form.js
stood out head and shoulders from the crowd."If you use and enjoy validate_form.js
, please consider adding your name or company to this list. I am grateful. Thanks
:' )
.
View the full text of the BSD License.
validate_form.js: A comprehensive solution for validating the most common rules in HTML forms.
http://sourceforge.net/projects/validateformjs
Copyright (C) 2003-2005, Jeff Epstein
All rights reserved.
Modifications: No
Redistribution in binary form, with or without modifications, are permitted provided that the following conditions are met:
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* If modifications are made to source code then this license should indicate that fact in the "Modifications" section above.
* Neither the author, nor the contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[NOTE: This license contains no advertising clause.]
Copyright (C) 2003-2005, Jeff Epstein. All rights reserved.