Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript form submit on button click check if required fields not empty

const checkEmpty = document.querySelector('#checkIt');
checkEmpty.addEventListener('input', function () {
  if (checkEmpty.value && // if exist AND
    checkEmpty.value.length > 0 && // if value have one charecter at least
    checkEmpty.value.trim().length > 0 // if value is not just spaces
  ) 
  { console.log('value is:    '+checkEmpty.value);}
  else {console.log('No value'); 
  }
});
Comment

javascript form submit on button click check if required fields not empty

<input type="text" id="checkIt" required />
Comment

PREVIOUS NEXT
Code Example
Javascript :: react img not showing 
Javascript :: angular dynamic class 
Javascript :: json to csv nodejs 
Javascript :: fetch api cors 
Javascript :: jsconfig.json 
Javascript :: Navbar Componet Nextjs 
Javascript :: sequelize delete item 
Javascript :: daysinmonth javascript 
Javascript :: how to upload file in material ui 
Javascript :: minecraft lang file 
Javascript :: jquery remove child 1 elemtn 
Javascript :: csrf token in js laravel 
Javascript :: angular load json file with httpclient 
Javascript :: Vuejs trigger function on route change 
Javascript :: js indexof regex 
Javascript :: ionic 3 alert 
Javascript :: internal/modules/cjs/loader.js:1122 return process.dlopen(module, path.toNamespacedPath(filename)); 
Javascript :: javascript get random number 
Javascript :: react-router react-router-dom 
Javascript :: jsx foreach 
Javascript :: add bootstrap to angular 13 
Javascript :: error: expected undefined to be a graphql schema. 
Javascript :: lodash convert object to array 
Javascript :: opening a link in another tab in react 
Javascript :: remove list content js 
Javascript :: dom element get attribute 
Javascript :: get placeholder innerhtml 
Javascript :: crop image canvas 
Javascript :: js add to array if not exists 
Javascript :: delta time js 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =