Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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 --

    secret_doom@hotmail.com
    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 --
    :
    : secret_doom@hotmail.com
    : 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 --

    secret_doom@hotmail.com
    batch.hpg.com.br

Sign In or Register to comment.