October 07, 2008, 16:27:45 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Revenue sharing launched. This is offered as a "thank you" for being a member of webmasterstalks.com community! If you have an Adsense/Yahoo publisher account then you can start right away !
 
  Home   Forum   Help Search Directory Calendar Login Register    RSS 2.0 feedAtom feed


News
Revenue sharing launched. This is offered as a "thank you" for being a member of webmasterstalks.com community! If you have an Adsense/Yahoo publisher account then you can start right away !
Pages: [1]
  Print  
Author Topic:

Check all input boxes

 (Read 1195 times)
0 Members and 1 Guest are viewing this topic.
bostam
Jr. Member
**

Points: 1
Offline Offline

Posts: 55


« on: June 14, 2006, 20:06:11 »

Is possible to check all "input" boxes from a page before submit ?

Thanks
Logged


TheGodFather
Administrator
Hero Member
*****

Points: 202
Offline Offline

Posts: 2570



WWW
« Reply #1 on: June 14, 2006, 20:21:10 »

You need to parse all dom of your code (is simple) and look after input tags. But  input can be multiple types, you want for all types or just for text ?

Regards
Logged

bostam
Jr. Member
**

Points: 1
Offline Offline

Posts: 55


« Reply #2 on: June 14, 2006, 21:06:00 »

Just for text. I only want to see if are empty or not before submiting and cancel the submit action.

Logged
TheGodFather
Administrator
Hero Member
*****

Points: 202
Offline Offline

Posts: 2570



WWW
« Reply #3 on: June 17, 2006, 11:45:09 »

This is the code.

The JS get all input tags (avoid the hidden and disable tags) and if is finding a empty field is just inform you about that.


Code:
function check_inputs()
{
    for( var i = 0; i < document.getElementsByTagName('input').length; i++ )
    {
        if ((document.getElementsByTagName('input')[i].value=="") && (document.getElementsByTagName('input')[i].type!="hidden") )
        {
            if (document.getElementsByTagName('input')[i].disabled!=true)
            alert(document.getElementsByTagName('input')[i].name+' este gol !\n  Please fill all the empty fields!'+document.getElementsByTagName('input')[i].disabled);
            else
            continue;
            return false;
        }
    }
return true;
}

to use him just look at the next code

Code:
<input type="submit" name="action" value="Search" onclick="return check_inputs();">

If you have an empty field then you cannot submit.

Regards
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.4 | SMF © 2006, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks

TinyPortal v0.9.7 © Bloc
Valid XHTML 1.0! Valid CSS!