Delete the only the first "0" in a textfield - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Delete the only the first "0" in a textfield

tschuettetschuette Posts: 11Member
hello,
i am a newbie. i am looking fpr a little script which deletes the first "0" in a textfield. does anyone can help me?
thanks a lot...
bye torsten

Comments

  • Secret_DoomSecret_Doom Posts: 116Member
    : hello,
    : i am a newbie. i am looking fpr a little script which deletes the first "0" in a textfield. does anyone can help me?
    : thanks a lot...
    : bye torsten

    Hi torsten. I'm not a experienced, but I think this will do it:




    function zeroout () {
    tmp = document.frm.field.value
    tmp1 = tmp.indexOf("0")
    tmp2 = tmp.substring(0,tmp1)
    tmp1++
    tmp3 = tmp.substring(tmp1)
    document.frm.field.value = tmp2 + tmp3
    }










    That's it. I hope I helped.

    -- Secret_Doom --

    [email protected]
    batch.hpg.com.br

  • tschuettetschuette Posts: 11Member
    hi,
    thanks a lot. but the script should only delete the zero on the first position. e.g. 05031 to 5031, but 5031 = 5031
    and it should work only on a few textfields, not on the whole form.
    perhaps i can change your script by myself, but if it is a little problem for you it would be great if you or someone other can help me a second time.
    thanks and bye
    torsten

    : : hello,
    : : i am a newbie. i am looking fpr a little script which deletes the first "0" in a textfield. does anyone can help me?
    : : thanks a lot...
    : : bye torsten
    :
    : Hi torsten. I'm not a experienced, but I think this will do it:
    :
    :
    :
    :
    : function zeroout () {
    : tmp = document.frm.field.value
    : tmp1 = tmp.indexOf("0")
    : tmp2 = tmp.substring(0,tmp1)
    : tmp1++
    : tmp3 = tmp.substring(tmp1)
    : document.frm.field.value = tmp2 + tmp3
    : }
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    : That's it. I hope I helped.
    :
    : -- Secret_Doom --
    :
    : [email protected]
    : batch.hpg.com.br
    :


  • Secret_DoomSecret_Doom Posts: 116Member
    : hi,
    : thanks a lot. but the script should only delete the zero on the first position. e.g. 05031 to 5031, but 5031 = 5031
    : and it should work only on a few textfields, not on the whole form.
    : perhaps i can change your script by myself, but if it is a little problem for you it would be great if you or someone other can help me a second time.
    : thanks and bye
    : torsten

    ----------------------

    Ooooh... Then it's much easier. This will do it:



    function zeroout () {
    tmp = document.frm.field.value.substring(0,1)
    if (tmp=="0") {
    document.frm.field.value = document.frm.field.value.substring(1)
    }
    }









    It's good to help.

    -- Secret_Doom --

    [email protected]
    batch.hpg.com.br

Sign In or Register to comment.