Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

disable submit button if input is empty

document.getElementById('submitID').disabled = true; //Disable at first

//Listen for keyup event (after we hit a key)
//-----------------------------------------------------------
//NOTE: We can also use the change event, but the submit button
//      won't update until we finish typing the whole thing
//-----------------------------------------------------------
document.getElementById('myInputFieldID').addEventListener('keyup', e => {
  //Check for the input's value
  if (e.target.value == "") {
    document.getElementById('submitID').disabled = true;
  }
  else {
    document.getElementById('submitID').disabled = false;
  }
});

//Happy coding :)
Comment

PREVIOUS NEXT
Code Example
Javascript :: express redirect 
Javascript :: how to stop browser back js history.pushState 
Javascript :: how to stop browser back js 
Javascript :: contains is not a function javascript 
Javascript :: delete element 
Javascript :: sls invoke local 
Javascript :: import react icons 
Javascript :: javascript allow only numeric characters 
Javascript :: how to take input in javascript in coding 
Javascript :: js document.addEventListner 
Javascript :: alphabet string javascript 
Javascript :: string contains character javascript 
Javascript :: vuex use state in action 
Javascript :: react native app crashes without error 
Javascript :: number of repetition in an array javascript 
Javascript :: get offset from timezone javascript 
Javascript :: react-native run-ios command 
Javascript :: jquery table row count 
Javascript :: if datatable is null js 
Javascript :: how to access key of object in javascript 
Javascript :: create an array of numbers 
Javascript :: chrome.tab.onupdated 
Javascript :: js insertbefore 
Javascript :: find in string javascript 
Javascript :: set data-id javascript 
Javascript :: how to show 1 day ago in javascript 
Javascript :: javascript array add front 
Javascript :: parent of heap node 
Javascript :: left join in sequelize 
Javascript :: for open new tab we are using window.open but new tab are open in left side how to change the right side 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =