Parcourir la source

Moved the form's behaviour setting to the JS script

Brendan Abolivier il y a 8 ans
Parent
révision
cfedd5cceb
2 fichiers modifiés avec 4 ajouts et 1 suppressions
  1. 3
    0
      front/form.js
  2. 1
    1
      front/index.html

+ 3
- 0
front/form.js Voir le fichier

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 Voir le fichier

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>