<HTML><HEAD>
<script language="javascript" type="text/javascript" src="tinymce/tiny_mce.js"></script>
<script language="javascript"><!--
if ( typeof tinyMCE != "undefined" ) {
tinyMCE.init({ theme : "simple",
mode : "specific_textareas",
debug : false });
}
// --></script>
<script language="javascript" type="text/javascript" src="../lib/Data/FormValidator.js"></script>
<script language="javascript"><!--
// Profile. This was dumped from perl via Data::JavaScript from the following structure:
/*
my $valid_profile = {
required => [qw( password1
tinymcetext
text1
select1
select2
select3
checkbox1
radio1
file1
submit1
)],
#textarea1
#reset1
#hidden1
optional => [qw( textarea1 text2
email
state
province
state_or_province
zip
postcode
zip_or_postcode
phone
american_phone
cc_number
cc_exp
cc_type
ip_address
)
],
dependencies => {
text1 => [ qw(textarea1 checkbox1) ],
},
dependency_groups => {
depend_group_1 => [qw(depend1 depend2 depend3)],
},
constraints => {
text1 => '/bob/i',
text2 => [{ name => 'text2', constraint => '/sam/i' },
{ name => 'text2b', constraint => '/mmy/i' }],
textarea1 => { name => 'textarea1', constraint => '/bob/i' } ,
tinymcetext => { name => 'tinymcetext', constraint => '/george/i' } ,
select1 => '/test/i',
select2 => '/test/i',
select3 => '/test/i',
email => 'email',
state => 'state',
province => 'province',
state_or_province => 'state_or_province',
zip => 'zip',
postcode => 'postcode',
zip_or_postcode => 'zip_or_postcode',
phone => 'phone',
american_phone => 'american_phone',
cc_number => 'cc_number',
cc_exp => 'cc_exp',
cc_type => 'cc_type',
ip_address => 'ip_address',
},
msgs => {
format => '%s',
invalid => 'Invalid data',
invalid_separator => ", ",
constraints => {
text2 => 'We are sorry, but the text2 field must contain the text \'sam\' somewhere within its message',
text2b => 'We are sorry, but the text2 field must contain the text \'mmy\' somewhere within its message',
select2 => 'We are sorry, but the textarea must contain the text \'bob\' somewhere within its message',
textarea1 => 'We are sorry, but the textarea must contain the text \'bob\' somewhere within its message',
tinymcetext => 'We are sorry, but the tinymcetext must contain the text \'george\' somewhere within its message',
},
},
};
*/
var myProfile = new Object;
myProfile.dependency_groups = new Object;
myProfile.dependency_groups.depend_group_1 = new Array;
myProfile.dependency_groups.depend_group_1[0] = 'depend1';
myProfile.dependency_groups.depend_group_1[1] = 'depend2';
myProfile.dependency_groups.depend_group_1[2] = 'depend3';
myProfile.constraints = new Object;
myProfile.constraints.select2 = '\/test\/i';
myProfile.constraints.text2 = new Array;
myProfile.constraints.text2[0] = new Object;
myProfile.constraints.text2[0].name = 'text2';
myProfile.constraints.text2[0].constraint = '\/sam\/i';
myProfile.constraints.text2[1] = new Object;
myProfile.constraints.text2[1].name = 'text2b';
myProfile.constraints.text2[1].constraint = '\/mmy\/i';
myProfile.constraints.select3 = '\/test\/i';
myProfile.constraints.tinymcetext = new Object;
myProfile.constraints.tinymcetext.name = 'tinymcetext';
myProfile.constraints.tinymcetext.constraint = '\/george\/i';
myProfile.constraints.select1 = '\/test\/i';
myProfile.constraints.text1 = '\/bob\/i';
myProfile.constraints.textarea1 = new Object;
myProfile.constraints.textarea1.name = 'textarea1';
myProfile.constraints.textarea1.constraint = '\/bob\/i';
myProfile.constraints.email = 'email';
myProfile.constraints.state = 'state';
myProfile.constraints.province = 'province';
myProfile.constraints.state_or_province = 'state_or_province';
myProfile.constraints.zip = 'zip';
myProfile.constraints.postcode = 'postcode';
myProfile.constraints.zip_or_postcode = 'zip_or_postcode';
myProfile.constraints.phone = 'phone';
myProfile.constraints.american_phone = 'american_phone';
myProfile.constraints.cc_number = 'cc_number';
myProfile.constraints.cc_exp = 'cc_exp';
myProfile.constraints.cc_type = 'cc_type';
myProfile.constraints.ip_address = 'ip_address';
myProfile.required = new Array;
myProfile.required[0] = 'password1';
myProfile.required[1] = 'tinymcetext';
myProfile.required[2] = 'text1';
myProfile.required[3] = 'select1';
myProfile.required[4] = 'select2';
myProfile.required[5] = 'select3';
myProfile.required[6] = 'checkbox1';
myProfile.required[7] = 'radio1';
myProfile.required[8] = 'file1';
myProfile.required[9] = 'submit1';
myProfile.dependencies = new Object;
myProfile.dependencies.text1 = new Array;
myProfile.dependencies.text1[0] = 'textarea1';
myProfile.dependencies.text1[1] = 'checkbox1';
myProfile.optional = new Array;
myProfile.optional[0] = 'textarea1';
myProfile.optional[1] = 'text2';
myProfile.optional[2] = 'email';
myProfile.optional[3] = 'state_or_province';
myProfile.optional[4] = 'state';
myProfile.optional[5] = 'province';
myProfile.optional[6] = 'zip_or_postcode';
myProfile.optional[7] = 'postcode';
myProfile.optional[8] = 'zip';
myProfile.optional[9] = 'phone';
myProfile.optional[10] = 'american_phone';
myProfile.optional[11] = 'cc_number';
myProfile.optional[12] = 'cc_exp';
myProfile.optional[13] = 'cc_type';
myProfile.optional[14] = 'ip_address';
myProfile.msgs = new Object;
myProfile.msgs.constraints = new Object;
myProfile.msgs.constraints.select2 = 'We are sorry\, but the textarea must contain the text \'bob\' somewhere within its message';
myProfile.msgs.constraints.text2 = 'We are sorry\, but the text2 field must contain the text \'sam\' somewhere within its message';
myProfile.msgs.constraints.tinymcetext = 'We are sorry\, but the tinymcetext must contain the text \'george\' somewhere within its message';
myProfile.msgs.constraints.text2b = 'We are sorry\, but the text2 field must contain the text \'mmy\' somewhere within its message';
myProfile.msgs.constraints.textarea1 = 'We are sorry\, but the textarea must contain the text \'bob\' somewhere within its message';
myProfile.msgs.invalid_separator = '\, ';
myProfile.msgs.format = '\%s';
myProfile.msgs.invalid = 'Invalid data';
// --></script>
<script language="javascript"><!--
// This is our small wrapper around Data.FormValidator, which our onSubmit() will call.
var click_once = 0;
function valid_data (frmObj) {
var goodColor = "#FFFFFF";
var badColor = "#FFFF99";
var profile = myProfile; // pulled from profile.js
// put any extras you'd like in here
if (click_once == 0) {
click_once = 1;
var passed = Data.FormValidator.check_and_report(frmObj, profile, goodColor, badColor);
if (passed) {
return true;
} else {
// reset click_once, so they can re-fillout the form
click_once = 0;
return false;
}
}
}
// -->
</script>
</HEAD><BODY BGCOLOR=#FFFFFF>
<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" WIDTH="100%" BGCOLOR="#000000"><TR><TD>
<TABLE BORDER="0" WIDTH="100%" BGCOLOR="#FFFFFF">
<TR>
<TD ALIGN="left"><H1><A HREF="http://formvalidatorjs.berlios.de/"><FONT COLOR="#000000">Data.FormValidator</FONT></A></H1></TD>
<TD ALIGN="right"><A href="http://developer.berlios.de" title="BerliOS Developer"> <img src="http://developer.berlios.de/bslogo.php?group_id=4847" width="124px" height="32px" border="0" alt="BerliOS Developer Logo"></A></TD>
</TR>
</TABLE>
<TABLE BORDER="0" WIDTH="100%" BGCOLOR="#DEDEEE">
<TR>
<TH><A HREF="https://developer.berlios.de/projects/formvalidatorjs/">Project Page</A></TH>
<TH><A HREF="http://www.openjsan.org/doc/u/un/unrtst/Data/FormValidator/">JSAN listing</A></TH>
<TH><A HREF="http://formvalidatorjs.berlios.de/ex1.html">Demo</A></TH>
<TH><A HREF="https://developer.berlios.de/project/showfiles.php?group_id=4847">Download</A></TH>
</TR>
</TABLE>
</TD></TR></TABLE>
<B>This (ugly) form is an example of a few of the features of Data.FormValidator.js.<BR>
Please note, FAR more customized validation is possible with this module.</B>
<HR>
<SCRIPT LANGUAGE="javascript"><!--
document.write("(running with Data.FormValidator VERSION = ["+Data.FormValidator.VERSION+"]");
// --></SCRIPT>
<HR>
<FORM onSubmit="return valid_data(this);">
<INPUT TYPE=reset name=reset1 value=reset> <INPUT TYPE=submit name=submit1 value=submit><BR>
<BR>
password<INPUT TYPE=password name=password1 value=""> (required)<BR>
tinymce textarea<TEXTAREA name="tinymcetext" rows="3" mce_editable="true"></TEXTAREA>(required, must contain "george") (NOTE: this will only test the tinymce support if the TinyMCE library is loaded.)<BR>
textarea<TEXTAREA name=textarea1></TEXTAREA>(optional, but required if "text1" is filled in)<BR>
text 1<INPUT TYPE=text name=text1 value=""> (requird, must contain the text "bob")<BR>
text 1<INPUT TYPE=text name=text1 value=""> (requird, must contain the text "bob")<BR>
text 2<INPUT TYPE=text name=text2 value=""> (optional, but must contain both "sam" and "mmy" if it is filled in)<BR>
hidden<INPUT TYPE=hidden name=hidden1 value=""><BR>
select-one<SELECT name=select1>
<OPTION>testA NO VALUE EXPLICITLY SET
<OPTION value="test1">t e s t 1 asdfasdf
<OPTION value="test2">t e s t 2 asdfasdf
<OPTION value="balsdf">balsdf asdfasdf
</SELECT> (required, must contain "test")<BR>
select-multiple<SELECT name=select2 multiple>
<OPTION>testA NO VALUE EXPLICITLY SET
<OPTION value="test1">test1 asdfasdf
<OPTION value="test2">test2 asdfasdf
<OPTION value="balsdf">balsdf asdfasdf
</SELECT> (required, must contain "test")<BR>
select-one<SELECT name=select3>
<OPTION value="">testA VALUE EXPLICITLY SET TO ""
<OPTION value="">testB VALUE EXPLICITLY SET TO ""
<OPTION>testC NO VALUE EXPLICITLY SET
<OPTION value="test1">t e s t 1 asdfasdf
<OPTION value="test2">t e s t 2 asdfasdf
<OPTION value="balsdf">balsdf asdfasdf
</SELECT> (required, must contain "test")<BR>
checkbox: asdf<INPUT TYPE=checkbox name=checkbox1 value="asfd">
qwer<INPUT TYPE=checkbox name=checkbox1 value="qwer">(required)<BR>
radio: 1<INPUT TYPE=radio name=radio1 value="1">
2<INPUT TYPE=radio name=radio1 value="2">(required)<BR>
dependency group: <INPUT TYPE=text name=depend1>
<INPUT TYPE=text name=depend2>
<SELECT name=depend3>
<OPTION value="">testa value set to ""
<OPTION value="">testb value set to ""
<OPTION>testc no value set
<OPTION value="test1">test 1
</SELECT>(if any of these are filled in, they all must be filled in)<br>
file: <INPUT TYPE=file name=file1>(required)<BR>
<HR>Build In Constraint Tests</HR>
email<INPUT TYPE="text" name="email"> (must contain valid email)<BR>
state<INPUT TYPE="text" name="state"> (must contain valid state)<BR>
province<INPUT TYPE="text" name="province"> (must contain valid province)<BR>
state_or_province<INPUT TYPE="text" name="state_or_province"> (must contain valid state_or_province)<BR>
zip<INPUT TYPE="text" name="zip"> (must contain valid zip)<BR>
postcode<INPUT TYPE="text" name="postcode"> (must contain valid postcode)<BR>
zip_or_postcode<INPUT TYPE="text" name="zip_or_postcode"> (must contain valid zip_or_postcode)<BR>
phone<INPUT TYPE="text" name="phone"> (must contain valid phone)<BR>
american_phone<INPUT TYPE="text" name="american_phone"> (must contain valid american_phone)<BR>
cc_number<INPUT TYPE="text" name="cc_number"> (must contain valid cc_number)<BR>
cc_exp<INPUT TYPE="text" name="cc_exp"> (must contain valid cc_exp)<BR>
cc_type<INPUT TYPE="text" name="cc_type"> (must contain valid cc_type)<BR>
ip_address<INPUT TYPE="text" name="ip_address"> (must contain valid ip_address)<BR>
<INPUT TYPE=hidden name=frmTarget value="testing">
</FORM>
</BODY></HTML>
Download :