Here it's working: https://jsfiddle.net/w711Lf6t/1/
On page don't working. index.php
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css.css">
<script src="js.js"></script>
</head>
<form action="register" method="post">
<input type="text" name="name" id="name" class="input_class" placeholder="test"/>
<div id="error_name">Input name!</div>
</form>
</html>
js.js
function validation() {
var name = $("#name").val();
if (name === '') {
$("#error_name").css('display', 'block');
}
else
{
$("#error_name").css('display', 'none');
}
}
$("#name").focusout(function () {
validation();
});
css.css
#error_name {
font-family: Arial;
color: red;
display: none;
}
What I forget to add? I try jquery .js, but same problem.