Like SystemiConnectFri 15 Oct 2021, 04:50
Auto Save MessagesLGforumFri 26 Feb 2021, 13:31
New tutorial questionTheCrowMon 15 Feb 2021, 08:12
Support iOS Emojis (and other platforms)LGforumSun 14 Feb 2021, 01:25
LGforum (2806)
Check if the user types something in input Vote_lcapCheck if the user types something in input Voting_barCheck if the user types something in input Vote_rcap 
Mr.Easybb (1587)
Check if the user types something in input Vote_lcapCheck if the user types something in input Voting_barCheck if the user types something in input Vote_rcap 
Bloodbath (745)
Check if the user types something in input Vote_lcapCheck if the user types something in input Voting_barCheck if the user types something in input Vote_rcap 
Rukiafan (533)
Check if the user types something in input Vote_lcapCheck if the user types something in input Voting_barCheck if the user types something in input Vote_rcap 
Dom (513)
Check if the user types something in input Vote_lcapCheck if the user types something in input Voting_barCheck if the user types something in input Vote_rcap 
puppycheese (446)
Check if the user types something in input Vote_lcapCheck if the user types something in input Voting_barCheck if the user types something in input Vote_rcap 
pedro (330)
Check if the user types something in input Vote_lcapCheck if the user types something in input Voting_barCheck if the user types something in input Vote_rcap 
Neymar (301)
Check if the user types something in input Vote_lcapCheck if the user types something in input Voting_barCheck if the user types something in input Vote_rcap 
Hitsu (281)
Check if the user types something in input Vote_lcapCheck if the user types something in input Voting_barCheck if the user types something in input Vote_rcap 
Flora (275)
Check if the user types something in input Vote_lcapCheck if the user types something in input Voting_barCheck if the user types something in input Vote_rcap 


Check if the user types something in input

HitsuHitsu
Status : Finished on working fmAPI.

Posts : 281
Join date : 2013-09-09
Age : 25
Location : Indonesia
Thu 09 Apr 2015, 06:46
Hello there, I want to ask, how can I check if the user types something in some specific input HTML?

Like this :

Code:
<input type="text" name="text" placeholder="text here..">
<script>
var inp = document.getElementsByTagName('input')[0];
if(inp.value.length += 1) {
 console.log('You typed something');
}
BloodbathBloodbath
Status : No status yet...

Posts : 745
Join date : 2013-05-31
Age : 28
Thu 09 Apr 2015, 08:22
Something like this should work.

Code:
var inp = document.getElementsByTagName("input")[0];
var addEventHandler = function(node, evt, f){
  if(node.addEventListener){
    node.addEventListener(evt, f;
  } else if(node.attachEvent){
    node.attachEvent('on'+evt, f);
  }
}
addEventHandler(inp, 'input', function(e){
  console.log("Your event has been triggered: "+e.data);
});

You'd have to wrap that in a DOM ready function.