10 examples of 'login form validation in javascript' in JavaScript

Every line of 'login form validation in javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
22onLogin(form) {
23 this.submitted = true;
24
25 if (form.valid) {
26 this.userData.login(this.login.username);
27 this.nav.push(TabsPage);
28 }
29}
52function loginSubmit(cb) {
53 //Enter Credentials and login to buzzport
54
55 var status = page.evaluate(function(username, password) {
56 if(document.title=="GT | GT Login") {
57 document.getElementById("username").value = username;
58 document.getElementById("password").value = password;
59 document.getElementsByClassName("btn-submit")[0].click();
60 return "success";
61 } else{
62 //haven't loaded GT login page yet, so
63 return "failure";
64 }
65
66 }, args[1], args[2]);
67 cb(status);
68
69},
44private login(form: any) {
45 if (form.invalid) return;
46 this.isLogin = true;
47 this._authService.login(this.user)
48 .then(data => {
49 messager.success("Login succeed!");
50 this._router.navigateByUrl(this.returnUrl);
51 })
52 .catch(err => {
53 this.isLogin = false;
54 messager.error(err);
55 });
56}
81function login($form) {
82 if ($form.valid()) {
83 form_loading($form);
84
85 var user = $form.find('[name=lg_username]').val();
86 var pass = $form.find('[name=lg_password]').val();
87
88 $.post(window.Rapidoid.contextPath + window.Rapidoid.loginUri, {username: user, password: pass}).done(function(data) {
89
90 if (data.success) {
91 form_success($form);
92
93 setTimeout(function() {
94 location.reload();
95 }, 300);
96 } else {
97 form_failed($form, options['msg-error']);
98 }
99
100 }).fail(function(data) {
101 swal("Communication error!", "Couldn't connect to the server!", "error");
102 console.log(data);
103 form_failed($form, "Couldn't connect to the server!");
104 });
105 }
106}
29validateForm() {
30 return this.state.email.length > 0 && this.state.password.length > 0;
31}
60private submit (): void {
61 this.$refs.form.validate(async (valid: boolean): Promise => {
62 if (valid) {
63 const data: Ajax.AjaxResponse = await this.$store.dispatch('login', { ...this.form })
64 if (data.code !== 1) return false
65 this.$router.push(this.$route.query.redirect || '/home')
66 return true
67 } else {
68 return false
69 }
70 })
71}
70function login(account, form) {
71 var p;
72 currentAccount = account;
73 if (account.isPasswordDecrypted) {
74 for (var i = 0; i < form.elements.length; i++) {
75 p = document.querySelector(form.elements[i].query);
76 if (p) {
77 p.value = account.elements[form.elements[i].name];
78 } else {
79 counter++;
80 window.setTimeout(startLogin, 200);
81 return;
82 }
83 }
84 if (form.submit) {
85 document.querySelector(form.submit).click();
86 } else {
87 p.form.submit();
88 }
89 } else {
90 window.setTimeout(requestPassword);
91 }
92}
60onLoginSubmit () {
61 this.validationError = '';
62
63 if (!this.username) {
64 this.validationError = 'Please enter your username';
65 return;
66 }
67
68 if (!this.password) {
69 this.validationError = 'Please enter your password';
70 return;
71 }
72
73 this.login({ username: this.username, password: this.password, rememberMe: this.rememberMe })
74 .then(() => {
75 this.$router.push({ name: 'welcome' });
76 })
77 .catch(({ response }) => {
78 this.password = '';
79 this.validationError = response.data.error.message;
80 });
81}
94handleSuccessfulLogin()
95{
96 this.props.setLoggedIn(this.state.email);
97 this.props.history.push('/Home');
98}
28function postLoginForm() {
29 if ($("#username").val() === "" || $("#password").val() === "") {
30 $(".weui_warn").text("请将信息填写完整!").show().delay(2000).hide(0);
31 } else {
32 $("#loadingToast, .weui_mask").show();
33 $.ajax({
34 url: '/wechat/userattach',
35 method: 'post',
36 data: {
37 username: $("#username").val(),
38 password: $("#password").val()
39 },
40 success: function (result) {
41 $("#loadingToast, .weui_mask").hide();
42 if (result.success) {
43 weui.alert('绑定教务系统账号成功', {
44 title: '绑定成功',
45 buttons: [{
46 label: '进入功能主页',
47 type: 'primary',
48 onClick: function () {
49 window.location.href = '/index';
50 }
51 }]
52 });
53 } else {
54 $("#loadingToast, .weui_mask").hide();
55 $(".weui_warn").text(result.message).show().delay(2000).hide(0);
56 }
57 },
58 error: function () {
59 $(".weui_warn").text("网络连接失败,请检查网络连接!").show().delay(2000).hide(0);
60 }
61 })
62 }
63}

Related snippets