This example script demonstrates Javascript validation when creating or editing records. To try it, click on the New record button in the applet below.
If the firstname is filled, then we validate that the lastname is also filled. If the firstname is empty, then we do not validate the lastname.
<script defer>
// if first name is set, then lastname must be set
function validatename()
{
if (document.phplens_ex309_edit.lens_FC_FIRSTNAME.value)
if (! document.phplens_ex309_edit.lens_FC_LASTNAME.value) {
alert('Both first and last name must be filled');
return '';
}
return 1;
}
</script>
If the javascript function returns:
0 or false, then the default error message will appear.
'' then we hide the default error message, so you can define your own error message.
1 or true, then the data is validated correctly.
This is a Demo. You can not change anything for security reasons.
Colors
General
Editing
Display
Formats
Templates
Titles
Menus
opens in a new window
Top Caption
Caption Background
Menu Color
Title Background
1
Odd Rows
2
Even Rows
3
Current Row
4
Row Number Background
Bottom Caption
Change Color Style:
Detail Table
Detail Left Column
Detail Right Column
Background
Warning: saving colors does not save settings from other tabs.
State & Debugging
NOTE: to edit hidden applet, set $_GET variable LENS_SHOW=1
SQL
SQL
Fields:
(; delimited fields)
Insert key SQL
Cancel You can modify settings in multiple tabs before saving.
PHPLens: 4.9.0 Data: 0.02 DB: mysql adodb: 4.62 Compat: 2 PHP: 4.3.10 OS: Linux License Type: Enterprise ID: (Natsoft;John Lim;jlim@natsoft.com) Valid Till: Never Expires
Editing Permissions
Enable this feature and show button
Edit Multiple Records in Grid
Enable this feature and show button
Enter name of global variable holding user id Redirect back on lock
Cancel You can modify settings in multiple tabs before saving.
PHPLens: 4.9.0 Data: 0.02 DB: mysql adodb: 4.62 Compat: 2 PHP: 4.3.10 OS: Linux License Type: Enterprise ID: (Natsoft;John Lim;jlim@natsoft.com) Valid Till: Never Expires
Display
Show Menu
Group rows by this database field
Table Width 100%
Normal borders Flat style Flat style with frames
Snaking Columns
(eg. 3^2)
Widths: (eg. 25%^20%) Mode:
Cancel You can modify settings in multiple tabs before saving.
PHPLens: 4.9.0 Data: 0.02 DB: mysql adodb: 4.62 Compat: 2 PHP: 4.3.10 OS: Linux License Type: Enterprise ID: (Natsoft;John Lim;jlim@natsoft.com) Valid Till: Never Expires
Date Formats
Captions
New Form Caption
Edit Form Caption
Filter Form Caption
Cancel You can modify settings in multiple tabs before saving.
PHPLens: 4.9.0 Data: 0.02 DB: mysql adodb: 4.62 Compat: 2 PHP: 4.3.10 OS: Linux License Type: Enterprise ID: (Natsoft;John Lim;jlim@natsoft.com) Valid Till: Never Expires
Store template file in applet/templates directory, and enter the file name below (leave out directory path)
Templates
Cancel You can modify settings in multiple tabs before saving.
PHPLens: 4.9.0 Data: 0.02 DB: mysql adodb: 4.62 Compat: 2 PHP: 4.3.10 OS: Linux License Type: Enterprise ID: (Natsoft;John Lim;jlim@natsoft.com) Valid Till: Never Expires
To modify titles of individual columns, Go Back to Grid and click on white "e" icons next to column titles.
Title Levels (Field^ColWidth^Title^Color;)
Cancel You can modify settings in multiple tabs before saving.
PHPLens: 4.9.0 Data: 0.02 DB: mysql adodb: 4.62 Compat: 2 PHP: 4.3.10 OS: Linux License Type: Enterprise ID: (Natsoft;John Lim;jlim@natsoft.com) Valid Till: Never Expires
Menus
Hide Top and Bottom Menu
Hide Top Menu
Hide Bottom Menu
Hide Scrolling
Hide Scroll to End
Hide Filter/Search
Hide Sort Form
Cancel You can modify settings in multiple tabs before saving.
PHPLens: 4.9.0 Data: 0.02 DB: mysql adodb: 4.62 Compat: 2 PHP: 4.3.10 OS: Linux License Type: Enterprise ID: (Natsoft;John Lim;jlim@natsoft.com) Valid Till: Never Expires
Cancel You can modify settings in multiple tabs before saving.
PHPLens: 4.9.0 Data: 0.02 DB: mysql adodb: 4.62 Compat: 2 PHP: 4.3.10 OS: Linux License Type: Enterprise ID: (Natsoft;John Lim;jlim@natsoft.com) Valid Till: Never Expires
Notes
When editing or creating new records, userid and password are set as must fill fields. Age only
accepts numbers (this is automatic, no programming required), and email addresses are validated.
create table lensusers (
USERID char(16) not null,
PASSWORD char(16) not null,
FIRSTNAME char(24) ,
LASTNAME char(24) not null,
EMAIL char(48) not null,
ADDRESS1 char(48) not null,
ADDRESS2 char(48) ,
POSTCODE char(12) ,
CITY char(24) ,
STATE char(24) ,
COUNTRY char(24) not null,
AGE integer,
CREATED datetime not null,
LASTMOD datetime not null,
primary key (userid)
);
This demo also shows you Google style scrolling. In this case, this is enabled by setting
$lens->scrollLinks = 9
which sets the number of scrolling links to 9.
sameRowLens
Also notice that the fields FirstName/LastName and PostCode/City are on the same line in the Details Grid, and New/Edit
record forms. This is configured by checking "2 Fields in 1 Row" in the column settings for PostCode.
sectionLens
We also have section breaks with "Misc" and "Address" using the sectionLens property.