Browse Source

Moved the form's behaviour setting to the JS script

Brendan Abolivier 8 years ago
parent
commit
cfedd5cceb
2 changed files with 4 additions and 1 deletions
  1. 3
    0
      front/form.js
  2. 1
    1
      front/index.html

+ 3
- 0
front/form.js View File

39
 function generateForm(id) {
39
 function generateForm(id) {
40
     var el = document.getElementById(id);
40
     var el = document.getElementById(id);
41
     
41
     
42
+    // Set the form's behaviour
43
+    el.setAttribute('onsubmit', 'sendForm(); return false;');
44
+    
42
     var input = {
45
     var input = {
43
         name: getField(items.name, 'Your name', false, 'input'), // TODO: configurable prefix
46
         name: getField(items.name, 'Your name', false, 'input'), // TODO: configurable prefix
44
         addr: getField(items.addr, 'Your e-mail address', true, 'input'),
47
         addr: getField(items.addr, 'Your e-mail address', true, 'input'),

+ 1
- 1
front/index.html View File

6
         <script src="http://localhost:1970/form.js" charset="utf-8"></script>
6
         <script src="http://localhost:1970/form.js" charset="utf-8"></script>
7
     </head>
7
     </head>
8
     <body>
8
     <body>
9
-        <form id="smam" onsubmit="sendForm(); return false;"></form>
9
+        <form id="smam"></form>
10
         <script type="text/javascript">
10
         <script type="text/javascript">
11
             generateForm('smam');
11
             generateForm('smam');
12
         </script>
12
         </script>