Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="navigation.html" method="post" id="query-form" class="form-signin">
- <input type="text" name="username" class="form-control" id="username" placeholder="Username">
- <input type="password" name="password" class="form-control" id="password" placeholder="Password">
- <button type="submit" class="btn btn-lg btn-primary btn-block" id="submit">
- Prisijungti
- </button>
- </form>
- <script>
- jQuery(document).ready(function($) {
- jQuery("#submit").click(function() {
- var username = jQuery("#username").val();
- var password = jQuery("#password").val();
- jQuery('#username, #password').removeClass("has_error");
- if (username === '') {
- jQuery('#username').addClass("has_error");
- return false;
- } else {
- jQuery('#username').removeClass("has_error");
- }
- if (password === '') {
- jQuery('#password').addClass("has_error");
- return false;
- } else {
- jQuery('#password').removeClass("has_error");
- }
- });
- });
- </script>
- jQuery("#submit").click(function(e) {
- e.preventDefault();
- var username = jQuery("#username").val();
- var password = jQuery("#password").val();
- //rest of code
- $('#query-form').submit(); // once checks complete
- });
- $(function() {
- $("#submit").click(function() {
- var $inputs = $(this).siblings('input'),
- isValid = true;
- $inputs.each(function() {
- var hasError = !$(this)[0].value.length;
- isValid = isValid && !hasError;
- $(this).toggleClass('has_error', hasError);
- });
- return isValid;
- });
- });
Add Comment
Please, Sign In to add comment