Toggle field on/off deopending on the length of another field

Posted on 2014-08-28
Last Modified: 2014-08-28
I am looking for some javascript to hide/show a div depending on the length of the string in a separate input field. For example; if the input field is the first line of an address and is less than 5 characters then hide the submit button.
Question by:cdjohn31
    1 Comment
    LVL 107

    Accepted Solution

    Please see
    <!DOCTYPE html>
    <html dir="ltr" lang="en-US">
    <!-- SEE -->
    <meta charset="utf-8" />
    <meta name="robots" content="noindex, nofollow" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script type="text/javascript" src=""></script>
            len = $("#addr").val().length;
            if (len > 4){
    <title>HTML5 Page in UTF-8 Encoding</title>
    <input id="addr">
    <input id="subm" type="submit" value="OK, Go!" />

    Open in new window

    This is about the minimum needed to do the trick.  Please post back if you have any questions.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do email signature updates give you a headache?

    Do you feel like all of your time is spent managing email signatures? Too busy to visit every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

    #Citrix #Internet Explorer #Enterprise Mode #IE 11 #IE 8
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
    In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now