sessionStorage on form submit

I am creating a form and the onsubmit attribute has a form validation boolean method. At the end of the method, it does not matter whether or not none of the invalid inputs have returned false, the sessionStorage variable is to be updated to true so that upon loading the page again the variable will be rechecked. Why is the variable still false whether none of the inputs returned false or not? Keep in mind that the form action attribute leads to the same page (form page). This is how my validation looks like:

<form onsubmit="return validate()">
var input=document.getElementById("foo"); // textbox
function validate()
{
   if (input.value.trim() === "") {
      return false;
   }
   sessionStorage.setItem("submitted","true");
}

Keep in mind that all form inputs exist and the sessionStorage is not updated even after the function doesn't return false.



from Recent Questions - Stack Overflow https://ift.tt/3zBqWLl
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)