May 15th, 2008 |
by Knix |
published in
javascript
function loopForm(form) {
var cbResults = ‘Checkboxes: ‘;
var radioResults = ‘Radio buttons: ‘;
for (var i = 0; i < form.elements.length; i++ ) {
if (form.elements[i].type == ‘checkbox’) {
[...]
April 14th, 2008 |
by Knix |
published in
javascript
function addContent(divName, content) {
document.getElementById(divName).innerHTML = content;
}
function setCookie(c_name,value,expiredays) {
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ “=” +escape(value)+((expiredays==null) ? “” : “;expires=”+exdate.toGMTString());
}
function getCookie(c_name) {
if (document.cookie.length>0) {
c_start=document.cookie.indexOf(c_name + “=”);
[...]
April 1st, 2008 |
by Knix |
published in
javascript
This JavaScript demo verifies that an email address is in the correct format and that the user has typed in the same address in both fields to prevent mistyping of the address. I have borrowed the regex for verifying the correct email format from a different site.
Demo
Email:
Please type in your email again:
February 28th, 2008 |
by Knix |
published in
javascript
function selectToggle(toggle, form) {
var myForm = document.forms[form];
for( var i=0; i < myForm.length; i++ ) {
if(toggle) {
myForm.elements[i].checked = “checked”;
[...]
February 27th, 2008 |
by Knix |
published in
javascript
function verifyForm(form) {
var userName = form.name.value;
var userEmail = form.email.value;
var success = 1;
if (!userName) {
document.getElementById(“usernameMsg”).style.display = “”;
form.name.style.backgroundColor = “yellow”;
[...]
February 21st, 2008 |
by Knix |
published in
javascript
Not all forms are meant to be static. Sometimes, you want to allow the users to add certain parts of the form as they need them. Here is a nice example of dynamically adding inputs to your form as users need them. In addition, an input limit has been implemented in the [...]