Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 146
  • Last Modified:

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

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.
0
cdjohn31
Asked:
cdjohn31
1 Solution
 
Ray PaseurCommented:
Please see http://iconoun.com/demo/temp_cdjohn31.php
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>

<!-- SEE http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28507149.html -->

<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="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function(){
    $("#subm").hide();
    $("#addr").keyup(function(){
        len = $("#addr").val().length;
        if (len > 4){
            $("#subm").show();
        }
    });
});
</script>

<title>HTML5 Page in UTF-8 Encoding</title>
</head>
<body>

<form>
<input id="addr">
<input id="subm" type="submit" value="OK, Go!" />
</form>

</body>
</html>

Open in new window

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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now