Ive been trying to do a side project to learn website coding and what not.
what im trying to do right now is a simple validation of a form, and to show error messages when the required rules are not met.
this is my login.html
<html>
<title>Login</title>
<head>
<link rel="stylesheet" href="csslogin.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src= "js/jquery.validate.js"></script>
<script src= "js/loginform.js"></script>
<head>
<body>
<h1 id="title"> Login Form </h1>
<div id="firstblock">
<form id= loginform>
<label id="formfield">Username:</label><br>
<input type="text" name="username" placeholder="Enter your Username"><br>
<label id="formfield">Password:</label><br>
<input type="password" name="password" placeholder="Enter your Password"><br>
<input type="submit" id="submitbtn" value="Login"><br>
<input type="checkbox" id="rembme" name="rememberme" value="true">
<label type="text" id="remblabel" style="">Remember me</label>
</form>
</div>
</body>
</html>
this is my loginform.js
$(document).ready(function() {
$('#loginform').validate({
rule:{
username:{
required: true,
minlength: 5
},
password:{
required: true,
}
},
messages:{
username: {
required: "Please Enter a Username",
minlength: "Your Username Must Be At Least 5 Characters"
},
password: {
required: "Please Enter a Password:",
}
}
})
})
When putting the required field in the html file input it works okay but I want to learn how to link it like this. I am not sure how to check if the js is even being imported properly, but as of right now my loginform.js isnt even using the rules or messages that ive set which leads me to believe im either linking the wrong js cdn hotlink which ive tried multiple different ones or that im missing some sort of line in my html file to link my js file.
Sorry for the messy post I have not posted on here in a long long time and am not really sure how to format it properly so I kinda just threw everything in I think someone would need to answer.