Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

change color of input if submit clicked and input is empty

HTML :
Text <input type="text">
<button>Click Me</button>
--------------------------
JQuery :
$("button").on("click",function(){
    if($("[type='text']").val() == null){
        $(this).css("border","2px solid red");
    } 
});
 
PREVIOUS NEXT
Tagged: #change #color #input #submit #clicked #input #empty
ADD COMMENT
Topic
Name
7+1 =