I have tried many things to do this so hopefully some1 can help fix this or has a suggestion i haven't already tried.
Using Ajax MaskedEdit on a Textbox to get SSN# (optional for the user so there is no validator enabled). I am getting rid of those prompt characters on page load so they only show when textbox is in focus... (u know "___-__-____") Please help...
The function below works in IE, Firefox, and Chrome.
<script type="text/javascript">
function ClearText() {
var abc = document.getElementById('<%= step1Table.ClientID %>');
if (abc != null) {
var socialnum = document.getElementById('<%= txtSSN.ClientID %>').value;
if (socialnum.toString() === "___-__-____") {
document.getElementById('<%= txtSSN.ClientID %>').value = "";
}
}
}
setTimeout('ClearText()', 1000);
</script>
I don't trust the Timeout technique, so I found some useful code referenced here, that I am using below.
For some reason when I call that same function it only works in IE but the line underlined in bold cannot find the txtSSN control in FF and Chrome, See Code below, thanks!
<script type="text/javascript">
function ClearText() {
var abc = document.getElementById('<%= step1Table.ClientID %>');
if (abc != null) {
var socialnum = document.getElementById('<%= txtSSN.ClientID %>').value;
if (socialnum.toString() === "___-__-____") {
document.getElementById('<%= txtSSN.ClientID %>').value = "";
}
}
}
var alreadyrunflag = 0 //flag to indicate whether target function has already been run
if (document.addEventListener)
document.addEventListener("DOMContentLoaded", function () { alreadyrunflag = 1; ClearText() }, false)
else if (document.all && !window.opera) {
document.write('<script type="text/javascript" id="contentloadtag" defer="defer" src="javascript:void(0)"><\/script>')
var contentloadtag = document.getElementById("contentloadtag")
contentloadtag.onreadystatechange = function () {
if (this.readyState == "complete") {
alreadyrunflag = 1
ClearText()
}
}
}
window.onload = function () {
setTimeout("if (!alreadyrunflag) ClearText()", 1000)
}
</script>
I also changed that line so thanks for pointing that out BU XI - MSFT...
But as I said before... I have verified that the function ClearText() is definately executing but the line I underlined in bold is not getting a value in Firefox, Chrome, or IE9 (just noticed IE9). The function works in IE8 but thats it. any assistance is
appreciated.
I found that moving the <script> tag containing my javascript below the <ScriptManager> tag on my page fixed the problem, and it now works in Firefox, Chrome, and IE8... but NOT IE9 :(
So the only thing I need now is to get IE9 working... If anyone here can read my code and see where IE9 might need a tweek please advise me. Thanks!
cool.asp
Member
544 Points
189 Posts
Ajax MaskedEdit shows unwanted characters
Feb 16, 2012 06:18 PM|LINK
I have tried many things to do this so hopefully some1 can help fix this or has a suggestion i haven't already tried.
Using Ajax MaskedEdit on a Textbox to get SSN# (optional for the user so there is no validator enabled). I am getting rid of those prompt characters on page load so they only show when textbox is in focus... (u know "___-__-____") Please help...
The function below works in IE, Firefox, and Chrome.
<script type="text/javascript"> function ClearText() { var abc = document.getElementById('<%= step1Table.ClientID %>'); if (abc != null) { var socialnum = document.getElementById('<%= txtSSN.ClientID %>').value; if (socialnum.toString() === "___-__-____") { document.getElementById('<%= txtSSN.ClientID %>').value = ""; } } } setTimeout('ClearText()', 1000); </script>I don't trust the Timeout technique, so I found some useful code referenced here, that I am using below.
For some reason when I call that same function it only works in IE but the line underlined in bold cannot find the txtSSN control in FF and Chrome, See Code below, thanks!
<script type="text/javascript"> function ClearText() { var abc = document.getElementById('<%= step1Table.ClientID %>'); if (abc != null) { var socialnum = document.getElementById('<%= txtSSN.ClientID %>').value; if (socialnum.toString() === "___-__-____") { document.getElementById('<%= txtSSN.ClientID %>').value = ""; } } } var alreadyrunflag = 0 //flag to indicate whether target function has already been run if (document.addEventListener) document.addEventListener("DOMContentLoaded", function () { alreadyrunflag = 1; ClearText() }, false) else if (document.all && !window.opera) { document.write('<script type="text/javascript" id="contentloadtag" defer="defer" src="javascript:void(0)"><\/script>') var contentloadtag = document.getElementById("contentloadtag") contentloadtag.onreadystatechange = function () { if (this.readyState == "complete") { alreadyrunflag = 1 ClearText() } } } window.onload = function () { setTimeout("if (!alreadyrunflag) ClearText()", 1000) } </script>Please help... Thanks!
chetan.sarod...
All-Star
65759 Points
11153 Posts
Re: Ajax MaskedEdit shows unwanted characters
Feb 17, 2012 02:41 AM|LINK
http://www.phpfreaks.com/forums/index.php?topic=257205.0
http://stackoverflow.com/questions/973045/document-getelementbyid-value-and-document-getelementbyid-checked-not-workin
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
BU XI - MSFT
All-Star
22367 Points
2704 Posts
Microsoft
Re: Ajax MaskedEdit shows unwanted characters
Feb 20, 2012 02:32 AM|LINK
Hello
Please try to modify your setTimout's to an function instead of text evaluation,
window.onload = function () {
setTimeout(function () {
if (!alreadyrunflag) ClearText()
}, 1000)
}
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
cool.asp
Member
544 Points
189 Posts
Re: Ajax MaskedEdit shows unwanted characters
Feb 20, 2012 03:19 PM|LINK
Thank you for the replies.
I also changed that line so thanks for pointing that out BU XI - MSFT...
But as I said before... I have verified that the function ClearText() is definately executing but the line I underlined in bold is not getting a value in Firefox, Chrome, or IE9 (just noticed IE9). The function works in IE8 but thats it. any assistance is appreciated.
cool.asp
Member
544 Points
189 Posts
Re: Ajax MaskedEdit shows unwanted characters
Feb 27, 2012 04:40 PM|LINK
I found that moving the <script> tag containing my javascript below the <ScriptManager> tag on my page fixed the problem, and it now works in Firefox, Chrome, and IE8... but NOT IE9 :(
So the only thing I need now is to get IE9 working... If anyone here can read my code and see where IE9 might need a tweek please advise me. Thanks!