faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

I have an exsisting form that needs to add a check (all blanks filled) before submitting.

Apr 8th, 2008 19:12
ha mo, Dave Clark, Laura L,


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Laura,
     This will check to make sure all text boxes are filled-in before 
allowing the form submit to continue:
<form action="" onsubmit="
 var ele = this.elements;
 var x, len = ele.length;
 for (x=0; x<len; ++x) {
   if(ele[x].type == 'text'
   && /^\s*$/.test(ele[x].value))
     alert('Text field value missing');
     ele[x].select();
     ele[x].focus();
     return false;
   }
 }
 return true;">
Take care,
Dave Clark
www.DaveClarkConsulting.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com