• #21553
    Salesforce | shariq shariq #1

    How to turn my input field empty on the button click?

    I am in situation where I need to get my input field empty on the button click, Please give the code if possible.

    Tagged: , ,

    #21576

    Hello Shariq,

    Add a check when the button is clicked to see if there is any text. If there isn’t, pop up an alert box (or some other form of feedback) to tell the user to enter data, and don’t do the button functionality.

    <input id=”myText” type=”text” onkeyup=”stoppedTyping()”>
    <input type=”button” value=”Click to begin!” id=”start_button” onclick=”verify()” disabled/>

    <script type=”text/javascript”>
    function stoppedTyping(){
    if(this.value.length > 0) {
    document.getElementById(‘start_button’).disabled = false;
    } else {
    document.getElementById(‘start_button’).disabled = true;
    }
    }
    function verify(){
    if myText is empty{
    alert “Put some text in there!”
    return
    }
    else{
    do button functionality
    }
    }
    </script>

    • This reply was modified 6 days, 6 hours ago by Salesforce | Radhakrishna Radhakrishna.
Viewing 2 posts - 1 through 2 (of 2 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending
Property of Forcetalks.com
Copyright 2017 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?