Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to check if all inputs are not empty with javascript

const inputFeilds = document.querySelectorAll("input");

const validInputs = Array.from(inputFeilds).filter( input => input.value !== "");

console.log(validInputs) //[array with valid inputs]
Comment

javascript check if input is empty

<!-- check if any input field in "Form" is empty using JS -->

<script type="text/javascript">
  function validateForm() {
    var a = document.forms["Form"]["answer_a"].value;
    var b = document.forms["Form"]["answer_b"].value;
    if (!a || !b) {
      alert("Please Fill All Required Fields");
      return false;
    }
  }
</script>

<form method="post" name="Form" onsubmit="return validateForm()" action="">
  <input type="text" name="answer_a" value="">
  <input type="password" name="answer_b" value="password">
</form>
Comment

PREVIOUS NEXT
Code Example
Javascript :: delete element in hash in javascript 
Javascript :: if else dart 
Javascript :: replace many chracters js 
Javascript :: dot env react native 
Javascript :: Disable button if one of the checkboxes are not checked 
Javascript :: javascript encode base64 
Javascript :: create node js api 
Javascript :: forin js 
Javascript :: stop keyframe animation javascript 
Javascript :: convert json to dataframe 
Javascript :: round number at 2 decimal places 
Javascript :: poo js 
Javascript :: html set textarea value 
Javascript :: Shortest ajax get method jquery 
Javascript :: discord js bot embed user profile picture 
Javascript :: javascript max array 
Javascript :: find from string in javascript 
Javascript :: dayjs now 
Javascript :: var notification = new Notification 
Javascript :: next router push 
Javascript :: how to check if checkbox is checked in jquery 
Javascript :: fetch Response object get content type 
Javascript :: convert date and time into epoch javascript 
Javascript :: how to enable click copy function using js 
Javascript :: js object loop 
Javascript :: quasar change port 
Javascript :: get the text of a tag 
Javascript :: react native modal close when click outside 
Javascript :: javascript filter array of objects by key 
Javascript :: insert property multiple documents mongodb 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =