If you have not yet read about forms yet, please FORMS HELP. If you are not familiar with javascript then you can learn a bit about it by going to my javascript tutorial. Not all the javascript codes will be explained in on this page.
Forms will use the ACTION and METHOD format and may include an onSubmit="..." like this:
The forms on this page do not have the ACTION attribute in them. If you copy & paste the codes into one of your files, it will not work, i.e. the form will not go anyplace! You will have to add the METHOD and ACTION attributes of the form.
This page will explain the basics of form validation:
for (i=0; i < thisfloat.length; i++) - is a loop. It begins with the counter, i, set to zero, 0, and each time it checks to see if i is less than the value of thisfloat.length, the number of characters in the number. If this is true then it check the if condition. If it is true, it increases i by 1 and continues checking the if condition.
The || - mean or
The case of the function name should remain the same in both the javascript and the call to it.
The name of the form, formfloat must be in the call to the checking function, CheckFloating in the form.
formfloat - is the name of the form and must be included in the form. But you can use any name you wish as long as the name is the same in the form and the javascript.
lower & upper values - they must be in the correct order.
alert("Floating Point Number Is OK!") - may be removed if you do not need the validation, true, to be shown.
return false // remove this line! - SHOULD BE REMOVED as I have it in there only so the page will not reload when the value is true.
Again, there are several important things to note in this code:
The form name, checkcharacters, must be present but can be any name you wish.
The name of the input box to check is characters. If you wish to use a different name then you must change it in the javascript script function as well as the form.
Other valid characters may be used by adding a && between each characters or set of characters. If you are using from a character to a character, like I did with the "a" || "z", then be sure that all characters in this range are valid.
The last two lines of code, the Alert and the return false may be eliminated.
Here I use the special javascript element, indexOf("character:,starting-position), where character can be an valid keyboard character and starting-positon will default to the 1st character in the characters that are being checked but may be set to any position within the length of the characters.
Please note that the position of a character in the total characters is the nth positon - 1 as the script will start counting from the 1st position as number 0, e.g. if there are 12 characters then the 1st character position is 0 and the last positon is 11!
Again, the form name must be used in the call between the () and then name of the email address entry must be email. It may be changed to any other name you wish but it must be the same in the form and the javascript code.