|
Javascript - Button
examples
Alert
button , Confirmation button ,
Image button , Next
button , Previous button , Prompt
button , Scrolling text button , Rotating
text button
|
Javascript - Background
Background
music , Background color/image ,
Fixed background image |
|
Javascript - Cookies
Set
cookie , get cookie
|
|
Javascript - Combo
Boxes
combo
with button , combo with out button ,
combo box & frame , Remote
control combo , double combo , Combo
remote control
|
|
Javascript - Form
form
validation, Check all checkboxes , uncheck
all checkboxes , limit checkbox items selected ,
invert the selection of checkboxes , lock
the checkbox , radio button links , set
field value , Select the text from field
|
Javascript - Frames
Creating
simple frame , Nested frames ,
Linking to another frame , Breaking
frame , page opens in the same frame,
page opens in a new window , loading
multiple frames , using forms in frame ,
back and forward statements in frame ,
pop-up window and frames ,
inline frames(<iframe> |
Javascript - Image
Image
rollover , Change image , Text
around image , Image button |
Javascript - Links
Underline
remover , Link description on status bar ,
hide link description on statusbar , Link description
on a layer , Change link color on mouseover ,
Coloring links , Reload
current page , Load the page on mouse over ,
view source code |
Javascript - Meta
tag
Using
metatag , nocache ,Meta
Redirect |
Javascript - Statusbar
Default
status , Changing message , flashing
text , typing text , scrolling
text , type in & scroll out ,
Link description on status , hide link description
on status , colored scrollbar |
Javascript - Table
Change
table color on mouse over , Highlight a row ,
Move data from one column to another |
Javascript - Text
Typing
text , scrolling text , change
text color ,Text
style , Format
text |
Javascript - Window
Open
new window , close the new window , create
full window , close main window ,
scrolling
up window , open pop up onload , six
second delayed pop up, shaking window ,
popup window and frame, URL ,
browser checking , page
forwarding , reload the current page |
Javascript - Misc.
Ad
rotater , copy data to clip board , view
source code , metatag , nocache |
|
Javascript Form Validation
Javascript Form Validation
Javascript FormValidator:
If you use javascript
to validate fields in a html Form, then here's a script that is extremely
useful.
See for yourself -->
Advantages:
1> Validates Fields:Validates
TEXT fields, SELECT fields, RADIO fields and TEXTAREA fields
2> Minimal coding:
The script that validates the form is in a separate .js file and the script
is very generic in nature.
You just have to add this
file as an "include" file to your html file and add a couple of arrays
3> TEXTAREA Validation:
TEXTAREA fields are validated so that even if only carriage returns
are entered into a TEXTAREA , validator will return an error message.
4> Customized Error messages:
You can specify your error messages into an array. The validator takes
care of the rest. no messy Coding!
How to use it?
Step 1:
Download the javascript file(formvalidation.js) and place it in the same
directory as your html file. Click here
to Download javascript file(formvalidation.js)
Step 2:
Add the following line under <head> of your html
<SCRIPT SRC="formvalidation.js"> </script>
Step 3:
Now you have to
define the field names that are to be validated. 3 arrays are used for
this purpose.
Add following scriptlet under
your <head> in your html and customize it as explained below:
<script>
ReqdFieldNames
= new Array("field1", "field2","field3", "field4");
FieldPrompts
= new Array("field1 Prompt", "field2 Prompt","field3 Prompt",
"field4 Prompt");
FieldTypes
= new Array(SELECTFLD, TEXTFLD, RADIOFLD, TEXTAREAFLD)
</script>
ReqdFieldNames
All Fields that are to be
validated should be to this Array. Replace field1..., with your form
field names (add only those that are to be validated).
Note: Javascript is case-sensitive.
Please enter field names as you use in your HTML form
Eg:if you have 2 fields
Name and Age in a form to be validated the array would be:
ReqdFieldNames
= new Array("Name", "Age");
FieldPrompts:
Prompts for these fields.
The validator uses these prompts when it finds an error.
Eg: FieldTypes
= new Array("Please enter Your Name", "Please enter Your Age");
FieldTypes:
Add the type of each fieldPrompts
for these fields. The validator uses these prompts when it finds an error.
Enter Field Types into this
Array.
For SELECT Fields use identifier
--> SELECTFLD,
For Text Fields use identifier
--> TEXTFLD
For Radio Fields use identifier
--> RADIOFLD
For TEXTAREA Fields use
identifier --> TEXTAREAFLD
Eg: FieldTypes
= new Array(TEXTFLD, TEXTFLD)
Step 4:
Modify your submit
button as follows:
<INPUT TYPE=button
onClick="if (ValidateForm() == true)
{
document.forms[0].submit()
}" VALUE="Submit">
That's it you are done! Good
luck!
|