Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

onsubmit in js

//This is the best way to use onsubmit in js

// ----------------JS
register_form = document.getElementById('register_form');

register_form.onsubmit = function(){
  console.log(register_form);
  console.log(register_form.email);
  console.log(register_form.password);
  return false;
};


// ----------------HTML
<form id="register_form">
    <div class="">
        <input required type="text" name="email" placeholder="Email Address">                        
    </div>
    <div class="">
        <input required type="password" name="password" placeholder="Password">
    </div>
</form>

 
PREVIOUS NEXT
Tagged: #onsubmit #js
ADD COMMENT
Topic
Name
3+3 =