www.webdeveloper.com
Results 1 to 2 of 2

Thread: Form Problem-Deals with Passwords

  1. #1
    Join Date
    Jul 2005
    Location
    Kentucky
    Posts
    162

    Form Problem-Deals with Passwords

    Hi, how do I make my form only submit all the rquired information. Like I want my users to put in thier first name, last name, email address, etc. But I want the form to only acept the information if all the questions have been answered. So I want get my email box full of registrations forms with nothing on them. Thanks to anyone that helps.

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
     "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="Content-Script-Type" content="text/javascript">
    <meta name="Content-Style-Type" content="text/css">
    <title>Example</title>
    
    <script type="text/javascript">
    function check (f) {
    	var e, i = 0
    	while (e = f.elements[i++]) {
    		if (e.type == 'text' && !/\S/.test (e.value)) {
    			alert ('Field "' + e.previousSibling.data + '" is required.')
    			e.focus()
    			return false
    			}
    		}
    }
    </script>
    
    <style type="text/css">
    fieldset {padding:1ex; width:12em}
    label {display:block; margin:1ex; text-align:right}
    input {margin-left:1ex; width:7em}
    button {display:block; margin:auto}
    </style>
    
    </head>
    <body>
    <form action="some-script.pl" onsubmit="return check (this)">
    <fieldset>
    <legend>Example</legend>
    <label>Name<input name="name" type="text"></label>
    <label>E-mail<input name="e-mail1" type="text"></label>
    <label><i lang="la" title="and the rest">Et cetera</i><input name="etc" type="text"></label>
    <button type="submit">Send</button>
    </fieldset>
    </form>
    </body>
    </html>
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles