Created
August 28, 2016 15:06
-
-
Save TonyRenHK/b3c1a1bd54546ca9fe6f92487d8df01c to your computer and use it in GitHub Desktop.
JQuery-Input-only-input-one-field.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> | |
<script src="https://code.jquery.com/jquery-1.10.2.js"></script> | |
<script> | |
$(document).ready(function(){ | |
$("#id1").keyup(function(){ | |
if(($('#id1').val().length > 0)){ | |
$("#id2").prop( "disabled", true ); | |
}else{ | |
$("#id2").prop( "disabled", false ); | |
} | |
}); | |
$("#id2").keyup(function(){ | |
if(($('#id2').val().length > 0)){ | |
$("#id1").prop( "disabled", true ); | |
}else{ | |
$("#id1").prop( "disabled", false ); | |
} | |
}); | |
}); | |
</script> | |
<style> | |
div { | |
background: #def3ca; | |
margin: 3px; | |
width: 80px; | |
display: none; | |
float: left; | |
text-align: center; | |
} | |
</style> | |
</head> | |
<body> | |
<form action=""> | |
Input1: <input type="text" name="user" id="id1"><br> | |
Input2: <input type="text" name="id" id="id2"> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment