Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have used javascript for transfer input text to uppercase in textbox.


<script>
function txt_SurName()
{
var x= document.getElementById("txt_SurName");
x.value=x.value.toUpperCase();

}
</script>


<asp:TextBox ID="txt_SurName" runat="server" onblur="txt_SurName()" ></asp:TextBox>


but it is not working.what is problem in my code.error is not grnerated.
Posted
Updated 23-Jan-13 19:08pm
v2

You Can used like
function txt_SurName()
{
var x= document.getElementById("txt_SurName");
x.value=x.value.toUpperCase();
 
}



<asp:TextBox ID="txt_SurName" runat="server" onblur="javascript:txt_SurName()" ></asp:TextBox>
 
Share this answer
 
Comments
Member 9720862 24-Jan-13 1:48am    
i have try it but not working.
Hi modify your javascript function as "Surname()" by removing the txt_ prefix.
Problem here is, your text box and the java script function has same name.
ASP.NET
<asp:textbox id="txt_SurName" runat="server" onblur="SurName()" xmlns:asp="#unknown"></asp:textbox>

HTML
<script>
function SurName()
{
var x= document.getElementById("txt_SurName");
x.value=x.value.toUpperCase();
 
}
</script>
 
Share this answer
 
Comments
Member 9720862 24-Jan-13 2:10am    
i have try this ,but not working
Tharaka MTR 24-Jan-13 3:05am    
Is it? I tried this, it works fine for me. are you control in inside the master page or panel etc..

then it may generates the different ID for text fields.
Member 9511889 25-Jan-13 0:51am    
i have used masterpage.this form is made using this masterpage.then where i have to put <script src="javascript/TextboxValidation.js" type="text/javascript"></script> link.i have put this link in masterpage.
try this

JavaScript
function makeUppercase(v)
        {
          v.value=v.value.toUpperCase();
        }


ASP.NET
<asp:TextBox name="txtCandidateName" runat="server" ID="txtCandidateName"                                                                         Width="205px" onblur="makeUppercase(this)" />
 
Share this answer
 
use this-
XML
<script type="text/javascript" language="javascript">
function txt_SurName()
{
var x= document.getElementById("txt_SurName");
x.value=x.value.toUpperCase();

}
</script>
 
Share this answer
 
Comments
Member 9511889 24-Jan-13 1:25am    
i have nt use inline javascript .i have used .js file.
AdityaPratapSingh 24-Jan-13 1:27am    
<script>
function txt_SurName(txt)
{
txt.value=txt.value.toUpperCase();

}
</script>

<asp:TextBox ID="txt_SurName" runat="server" onblur="txt_SurName(this)" >
[no name] 24-Jan-13 2:44am    
It work fine but you need to do the change either textbox id or function name because you gave both same.
rizwan muhammed khan gouri 24-Jan-13 1:41am    
I tried it but its not working
Member 9720862 24-Jan-13 1:48am    
i have also try it but not working.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900