Not sure if this is what you mean. But I’ve created a sample here where every click event it will get the value of the input fields.
<input type="text" id="name"/>
<input type="text" id="number"/>
<button id="getvalue">Get value</button>
Here’s the js
$(document).ready( function(){
$('#getvalue').click( function() {
var nameVal = $('#name').val();
var numVal = $('#number').val();
if(nameVal == '' || numVal == ''){
alert('Empty fields.')
}else{
alert('Name is ' + nameVal + ' and Number is ' + numVal);
}
});
});
You need to have a trigger event in order for javascript to communicate with your html elements. In this case we are using a click event through button element.
Here’s a working sample
solved How can I get the new value of an input with jquery