Been trying to see how flexible this is. http://jsfiddle.net/PJSha/4/ i have changed the get element from Name to ClassName which both worked but does not work when i try and achieve it with Id… is there a reason
Code:
<link rel="stylesheet" href="http://code.jquery.com/ui/1.8.21/themes/base/jquery-ui.css" type="text/css" media="all" />
<input type="text" id="foo" class="bar" name="domain">
<div onclick="check_domain_input()">Click</div>
<div id="dialog" title="Attention!" style="display:none">
Please enter a domain name to search for.
</div>
<script>
function check_domain_input() {
var domain_val = document.getElementById('foo');
if (domain_val[0].value.length > 0) {
return true;
}
$( "#dialog" ).dialog();
return false;
}
</script>
getElementsByIdshould begetElementById(nosafterElement). It only ever returns a reference to one element, ornull.Because it returns a reference, not a
NodeList, the[0]is not necessary when you access itsvalueproperty.