Provide me an If/Then statement to determine if a DHTML text box is empty and stop running code.
I required this immediately.... i will be highly thankful!!!!!!
I required this immediately.... i will be highly thankful!!!!!!
<!-- A text input --> <input type="text" id="myBox" value="" /> <!-- or for a textarea --> <textarea id="myBox" cols="10" rows="3"></textarea>
// Get a reference to the html element
var textbox = document.getElementById("myBox");
// Ensure that the element was found
if(textbox !== null){
// Check the value - i.e. the text in the box.
if(textbox.value === ''){
//Textbox is empty so do something
}else{
//Textbox is not empty so do something else.
}
}
Comment