I have some problem regarding JavaScript compatibility. I am using below code to clean text box blur data when click on that Text Box.This code is working fine in Firefox 3.6 & IE, but not supportable on Firefox 4. Some errors are there in error console like clearTextFrom is not defined
& clearTextTo is not define
. Please check below code & suggest me how can i run this code on FF4.
function clearTextFrom() {
if(document.getElementById("size_from").value=="From Year")
document.getElementById("size_from").value="";
}
function clearTextTo() {
if(document.getElementById("size_to").value=="To Year")
document.getElementById("size_to").value="";
}
Waiting for your quick response.
Thanks in Advance Tanu
EDIT:
<div class="yearsearch">
<input type='text' style='width: 60px;' name='size_from' maxlength='4' size='17' id='size_from' onfocus='clearTextFrom();' onkeyup="validNumbers(document.getElementById('size_开发者_JAVA技巧from')); sync();"/>
<input type='text' style='width: 60px;' name='size_to' maxlength='4' size='17' id='size_to' onfocus='clearTextTo();' onkeyup="validNumbers(document.getElementById('size_to'));"/>
</div>
This is the code which i am using to call these functions.
Change to this :
<script language="javascript">
function clearTextFrom(item) {
if(item.value=="From Year")
item.value="";
}
function clearTextTo(item) {
if(item.value=="To Year")
item.value="";
}
</script>
<div class="yearsearch">
<input type='text' style='width: 60px;' name='size_from' maxlength='4' size='17' id='size_from' onfocus='clearTextFrom(this);' value="From Year"/>
<input type='text' style='width: 60px;' name='size_to' maxlength='4' value="To Year" size='17' id='size_to' onfocus='clearTextTo(this);'/>
</div>
in this code you are sending each textbox to related function. I tested and worked for me in FF4.0
sample : http://jsfiddle.net/fkP2P/
精彩评论