• #21553
    Salesforce | shariq shariq #2
    Forcetalks

    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
    Forcetalks

    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 4 months, 1 week 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

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

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

Log in with your credentials

or    

Forgot your details?