File: 3a-test05.html

package info (click to toggle)
libcgi-formbuilder-perl 3.08-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,204 kB
  • sloc: perl: 7,201; makefile: 13
file content (48 lines) | stat: -rw-r--r-- 1,913 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<script type="text/javascript"><!-- hide from old browsers
function validate (form) {
    var alertstr = '';
    var invalid  = 0;
    var invalid_fields = new Array();

    // email: standard text, hidden, password, or textarea box
    var email = form.elements['email'].value;
    if (email != null && email != "" && ! email.match(/^[\w\-\+\._]+\@[a-zA-Z0-9][-a-zA-Z0-9\.]*\.[a-zA-Z]+$/)) {
        alertstr += '- Invalid entry for the "Email" field\n';
        invalid++;
        invalid_fields.push('email');
    }
    // first_name: standard text, hidden, password, or textarea box
    var first_name = form.elements['first_name'].value;
    if (first_name == null || first_name === "") {
        alertstr += '- Invalid entry for the "First Name" field\n';
        invalid++;
        invalid_fields.push('first_name');
    }
    if (invalid > 0 || alertstr != '') {
        if (! invalid) invalid = 'The following';   // catch for programmer error
        alert(''+invalid+' error(s) were encountered with your submission:'+'\n\n'
                +alertstr+'\n'+'Please correct these fields and try again.');
        return false;
    }
    return true;  // all checked ok
}
//-->
</script>
<noscript><font color="#cc0000"><b>Please enable Javascript or use a newer browser.</b></font></noscript>
<p>Fields that are <b>highlighted</b> are required.</p>
<form action="TEST" method="get" onsubmit="return validate(this);">
<div><input id="_submitted" name="_submitted" type="hidden" value="1" /></div>
<table>
<tr valign="top">
  <td>Email</td>
  <td><input id="email" name="email" type="text" value="nate@wiger.org" /></td>
</tr>
<tr valign="top">
  <td><b>First Name</b></td>
  <td><input id="first_name" name="first_name" type="text" value="Nate" /></td>
</tr>
<tr valign="top">
  <td align="center" colspan="2"><input id="_submit" name="_submit" type="submit" value="Submit" /></td>
</tr>
</table>
</form>