Click here to Skip to main content
15,902,299 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Peoples
could you please give me a solution for this?
I want to remove first zero from numeric string in the input string of the textbox,without removing actual string,actually i used regular expression for the same,but after pressing 'home' and 'zero',it deletes the first charachter from the input..
waiting for your reply...
Posted

JavaScript substring() Method[^]

XML
<script type="text/javascript">

var str="0123456";
document.write(str.substring(0)+"<br />");
</script>


output:123456
 
Share this answer
 
C#
function TrimStr(js_val)
{
    var js_rslt="";
    var js_flg=false;
    var ls_substr="";
        if(js_val!="")
        {
            ji_ln=js_val.length;
            for(i=0 ; i<ji_ln ; i++)
            {
                ls_substr=js_val.substring(i,i+1);
                if (isNaN(parseInt(ls_substr))==0 && js_flg==false )
                {
                   js_flg=true;
                }
                else
                {
                    js_rslt+=ls_substr;
                }
             }
         }

         alert(js_rslt);
}
 
Share this answer
 

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