Good Day!!!
In this tutorial, we are going to learn
How To Make Register Form with JQuery Validation. This is simple project and it consists firstname, lastname, username, password, confirm password, email and agree for the terms.
You can use it to your Website or System.
Directions:
For JQuery Validation
<script>
$().ready(function() {
$("#register_form").validate({
rules: {
firstname: "required",
lastname: "required",
username: {
required: true,
minlength: 2
},
password: {
required: true,
minlength: 5
},
confirm_password: {
required: true,
minlength: 5,
equalTo: "#password"
},
email: {
required: true,
email: true
},
topic: {
required: "#newsletter:checked",
minlength: 2
},
agree: "required"
},
messages: {
firstname: " <span style='color:red;'>*</span> Enter your firstname",
lastname: " <span style='color:red;'>*</span> Enter your lastname",
username: {
required: " <span style='color:red;'>*</span> Enter a username",
minlength: " <span style='color:red;'>*</span> Your username must consist of at least 2 characters"
},
password: {
required: " <span style='color:red;'>*</span> Provide a password",
minlength: " <span style='color:red;'>*</span> Your password must be at least 5 characters long"
},
confirm_password: {
required: " <span style='color:red;'>*</span> Confirm your password",
minlength: " <span style='color:red;'>*</span> Your password must be at least 5 characters long",
equalTo: " <span style='color:red;'>*</span> Enter the same password as above"
},
email: " <span style='color:red;'>*</span> Enter a valid email address",
agree: " <span style='color:red;'>*</span> Agree to our terms"
}
});
});
</script>
For CSS Code
<style type="text/css">
body {
margin:0;
padding:0;
font-family:"Calibri";
}
table {
border:3px groove #CCC;
}
.btn_submit {
font-size:20px;
font-weight:bold;
border-radius:5px;
}
.btn_cancel {
font-size:20px;
font-weight:bold;
border-radius:5px;
}
input {
font-size:18px;
text-indent:4px;
}
label {
color:#0000ff;
font-size:20px;
}
</style>
For HTML Code
<form id="register_form" method="post">
<table border="1" cellspacing="5" cellpadding="5">
<input id="firstname" name="firstname" placeholder="Firstname..." type="text" />
<input id="lastname" name="lastname" placeholder="Lastname..." type="text" />
<input id="username" name="username" placeholder="Username..." type="text" />
<input id="password" name="password" placeholder="Password..." type="text" />
<label for="confirm_password">Confirm Password
</label>
<input id="confirm_password" placeholder="Confirm Password..." name="confirm_password" type="text" />
<input id="email" name="email" placeholder="Email..." type="text" />
<input type="checkbox" class="checkbox" id="agree" name="agree" />
<td colspan="2" align="center">
Full Source Code
<!DOCTYPE html>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
$().ready(function() {
$("#register_form").validate({
rules: {
firstname: "required",
lastname: "required",
username: {
required: true,
minlength: 2
},
password: {
required: true,
minlength: 5
},
confirm_password: {
required: true,
minlength: 5,
equalTo: "#password"
},
email: {
required: true,
email: true
},
topic: {
required: "#newsletter:checked",
minlength: 2
},
agree: "required"
},
messages: {
firstname: "
<span style='color:red;'>*
</span> Enter your firstname",
lastname: "
<span style='color:red;'>*
</span> Enter your lastname",
username: {
required: "
<span style='color:red;'>*
</span> Enter a username",
minlength: "
<span style='color:red;'>*
</span> Your username must consist of at least 2 characters"
},
password: {
required: "
<span style='color:red;'>*
</span> Provide a password",
minlength: "
<span style='color:red;'>*
</span> Your password must be at least 5 characters long"
},
confirm_password: {
required: "
<span style='color:red;'>*
</span> Confirm your password",
minlength: "
<span style='color:red;'>*
</span> Your password must be at least 5 characters long",
equalTo: "
<span style='color:red;'>*
</span> Enter the same password as above"
},
email: "
<span style='color:red;'>*
</span> Enter a valid email address",
agree: "
<span style='color:red;'>*
</span> Agree to our terms"
}
});
});
body {
margin:0;
padding:0;
font-family:"Calibri";
}
table {
border:3px groove #CCC;
}
.btn_submit {
font-size:20px;
font-weight:bold;
border-radius:5px;
}
.btn_cancel {
font-size:20px;
font-weight:bold;
border-radius:5px;
}
input {
font-size:18px;
text-indent:4px;
}
label {
color:#0000ff;
font-size:20px;
}
<form id="register_form" method="post">
<table border="1" cellspacing="5" cellpadding="5">
<input id="firstname" name="firstname" placeholder="Firstname..." type="text" />
<input id="lastname" name="lastname" placeholder="Lastname..." type="text" />
<input id="username" name="username" placeholder="Username..." type="text" />
<input id="password" name="password" placeholder="Password..." type="text" />
<label for="confirm_password">Confirm Password
</label>
<input id="confirm_password" placeholder="Confirm Password..." name="confirm_password" type="text" />
<input id="email" name="email" placeholder="Email..." type="text" />
<input type="checkbox" class="checkbox" id="agree" name="agree" />
<td colspan="2" align="center">
So what can you say about this work? Share your thoughts in the comment section below or email me at
[email protected]. Practice Coding. Thank you.
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.