10 examples of 'registration form validation using javascript in jsp' in JavaScript

Every line of 'registration form validation using javascript in jsp' 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
this disclaimer
22validateForm() {
23 return this.state.username.length > 0 && this.state.password.length > 0 && this.state.confirmPassword.length > 0 && this.state.password === this.state.confirmPassword;
24}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

224function reg_validForm(a) {
225 $(".has-error", a).removeClass("has-error");
226 var d = 0,
227 c = [];
228 $(a).find("input.required,textarea.required,select.required,div.required").each(function() {
229 var b = $(this).prop("tagName");
230 "INPUT" != b && "TEXTAREA" != b || "password" == $(a).prop("type") || "radio" == $(a).prop("type") || "checkbox" == $(a).prop("type") || $(this).val(trim(strip_tags($(this).val())));
231 if (!validCheck(this)) return d++, $(".tooltip-current", a).removeClass("tooltip-current"), $(this).addClass("tooltip-current").attr("data-current-mess", $(this).attr("data-mess")), validErrorShow(this), !1
232 });
233 d || (c.type = $(a).prop("method"), c.url = $(a).prop("action"), c.data = $(a).serialize(), formErrorHidden(a), $(a).find("input,button,select,textarea").prop("disabled", !0), $.ajax({
234 type: c.type,
235 cache: !1,
236 url: c.url,
237 data: c.data,
238 dataType: "json",
239 success: function(b) {
240 var c = $("[onclick*='change_captcha']", a);
241 c && c.click();
242 "error" == b.status ? ($("input,button,select,textarea", a).prop("disabled", !1), $(".tooltip-current", a).removeClass("tooltip-current"), "" != b.input ? $(a).find("[name=\"" + b.input + "\"]").each(function() {
243 $(this).addClass("tooltip-current").attr("data-current-mess", b.mess);
244 validErrorShow(this)
245 }) : ($(".nv-info", a).html(b.mess).addClass("error").show(), $("html, body").animate({
246 scrollTop: $(".nv-info", a).offset().top
247 }, 800))) : ($(".nv-info", a).html(b.mess + '<span class="load-bar"></span>').removeClass("error").addClass("success").show(), ("ok" == b.input ? setTimeout(function() {
248 $(".nv-info", a).fadeOut();
249 $("input,button,select,textarea", a).prop("disabled", !1);
250 $("[onclick*=validReset]", a).click()
251 }, 6E3) : $("html, body").animate({
252 scrollTop: $(".nv-info", a).offset().top
253 }, 800, function() {
254 $(".form-detail", a).hide();
255 setTimeout(function() {
256 window.location.href = "" != b.input ? b.input : window.location.href
257 }, 6E3)
258 })))
259 }
260 }));
261 return !1
262}
39onSubmit() {
40 this.af.auth.createUserWithEmailAndPassword(this.registration.value.email, this.registration.value.password)
41 .then((success: any) => {
42 this.db.object("/users/" + success.uid).update({
43 name: this.registration.value.name,
44 email: this.registration.value.email,
45 mobileNo: this.registration.value.mobileNo,
46 role: "User"
47 });
48 localStorage.setItem("uid", success.uid);
49 this.navCtrl.setRoot("HomePage");
50 }).catch(error => {
51 console.log("Firebase failure: " + JSON.stringify(error));
52 this.showAlert(error.message);
53 });
54}
113function register()
114{
115 var reg_username=$("div#register #username").val();
116 var reg_email=$("div#register #email").val();
117 var reg_password=$("div#register #password").val();
118 var reg_repassword=$("div#register #repassword").val();
119
120 if(reg_username=="" || reg_email=="" || reg_password=="" || reg_repassword=="")
121 {
122 $("div#register div#warning").html("All fields are required");
123 return;
124 }
125
126 if(reg_password!=reg_repassword)
127 {
128 $("div#register div#warning").html("Passwords are not the same");
129 return;
130 }
131
132 $.get("/php/brainspell.php",{"action":"register","username":reg_username,"email":reg_email,"password":reg_password},function(data){
133 if(data=="Yes")
134 {
135 username=reg_username;
136 loggedin=1;
137 $("div.login").remove();
138 console.log("[register] calling update_login");
139 update_login();
140 }
141 else
142 if(data=="Exists")
143 {
144 $("div#register div#warning").html("That username is already in use");
145 }
146 else
147 {
148 $("div#register div#warning").html("Sorry, your registration failed. Please try again later");
149 }
150 });
151}
15register(form) {
16 this.submitted = true;
17
18 if (form.$valid) {
19 this.Auth.createUser({
20 name: this.user.name,
21 email: this.user.email,
22 password: this.user.password
23 })
24 .then(() => {
25 // Account created, redirect to home
26 this.$state.go('main');
27 })
28 .catch(err => {
29 err = err.data;
30 this.errors = {};
31
32 // Update validity of form fields that match the mongoose errors
33 angular.forEach(err.errors, (error, field) => {
34 form[field].$setValidity('mongoose', false);
35 this.errors[field] = error.message;
36 });
37 });
38 }
39}
5get confirmPassword () { return $('input[name="confirmPassword"]'); }
111private hasPasswordConfirmValidationErrors(): boolean {
112 const password = this.registrationFormElement.dataForm.getPropertyByName("password");
113 const passwordConfirm = this.registrationFormElement.dataForm.getPropertyByName("passwordConfirm");
114
115 if (password.valueCandidate !== passwordConfirm.valueCandidate) {
116 passwordConfirm.errorMessage = "Password does not match the confirm password.";
117 this.registrationFormElement.dataForm.notifyValidated("passwordConfirm", false);
118
119 return true;
120 }
121
122 return false;
123}
17function validateForm()
18{
19 var message = "";
20 var returnValue = true;
21 var fm = document.getElementById("fm");
22 if(fm.firstName.value == "")
23 {
24 message += "- The field First Name is Mandatory \n";
25 returnValue = false;
26 }
27 if(fm.lastName.value == "")
28 {
29 message += "- The field Last Name is Mandatory \n";
30 returnValue = false;
31 }
32 if(fm.email.value == "")
33 {
34 message += "- The field Email is Mandatory \n";
35 returnValue = false;
36 }
37 if(!returnValue)
38 {
39 message = "Please correct the following errors:\n\n" + message;
40 alert(message);
41 }
42 return returnValue;
43}
17function onRegisterBtn()
18{
19 var email = $("#reg_email").val();
20 var password = $("#reg_password").val();
21console.log(MC);
22 MC.User.register(email, password)
23 .done(function()
24 {
25 console.log('Registration is success!' + MC.User._oid);
26 $.mobile.changePage('#ListPage');
27 })
28 .fail(function(err)
29 {
30 console.log('FAILED');
31 alert('Registration failed!');
32 console.error(JSON.stringify(err));
33 });
34}
32function validateForm() {
33 var user = document.forms["myForm"]["user"].value;
34
35 if(user.trim() == "") {
36 document.getElementById("userError").innerHTML = "Remplir le champ svp !";
37 return false;
38 }
39 return true;
40}

Related snippets