From eb198d97ba8cff28414d9aaed06a3bc0ac9b122f Mon Sep 17 00:00:00 2001 From: German Correa Date: Wed, 29 Nov 2017 22:30:48 -0300 Subject: [PATCH] Improvements in register form validation --- header.php | 3 ++ js/registerform.js | 76 +++++++++++++++++++++++++++++++++++++--------- registration.php | 53 +++++++++++++++++++++----------- 3 files changed, 100 insertions(+), 32 deletions(-) diff --git a/header.php b/header.php index 0486187..7cd5fe4 100644 --- a/header.php +++ b/header.php @@ -17,6 +17,9 @@ + + + diff --git a/js/registerform.js b/js/registerform.js index 341af93..7d94c49 100644 --- a/js/registerform.js +++ b/js/registerform.js @@ -1,7 +1,8 @@ $().ready(function(){ $("#statusmsg").hide(); - $("#txtbda,#txteda").datepicker({ + $("#txtbda,#txteda").datepicker({ + minDate:new Date(2018,7,23), maxDate:new Date(2018,7,27) }); @@ -37,10 +38,13 @@ $().ready(function(){ required: true, email: true }, + invited:{required:true}, + financiacion:"required", + letterinvited:"required", }, - mesagges: { + messages: { nombre: { required: "Please enter your firstname", minlength: "Your firstname must be at least 2 characters long" @@ -50,33 +54,77 @@ $().ready(function(){ minlength: "Your lastname must be at least 2 characters long" }, email: "Please enter a valid e-mail address", + invited: "Select one option please", + financiacion: "Select one option please", + letterinvited: "Select one option please" + + + }, errorElement: "em", errorPlacement: function ( error, element ) { // Add the `help-block` class to the error element - error.addClass( "help-block" ); - element.parents(".col-sm-8").addClass("has-feedback"); - if ( element.prop( "type" ) === "checkbox" ) { - error.insertAfter( element.parent( "label" ) ); + + element.parents(".input-container").addClass("has-feedback"); + var esradio = element.prop("type") == "radio"; + var pariente; + if ( esradio ) { + pariente = element.parents(".form-group").children(".radioerror"); + + pariente.append(error); + //element.parents(".form-group").children(".radioerror").append(error); + //element.parents(".radios").append(error); + } else { + error.addClass( "help-block" ); error.insertAfter( element ); } - if ( !element.next( "span" )[ 0 ] ) { + if ( !element.next( "span" )[ 0 ] && !esradio ) $( "" ).insertAfter( element ); - } + if(esradio) + element.parents(".form-group").children(".radioerror").prepend(""); + }, success: function(label,element){ - if ( !$( element ).next( "span" )[ 0 ] ) { - $( "" ).insertAfter( $( element ) ); + var esradio = $(element).prop("type") == "radio"; + var pariente; + if ( esradio ) { + pariente = $(element).parents(".form-group").children(".radioerror"); + if (!$(pariente).children("span")[ 0 ]) + pariente.preprend(""); } + else if ( !$( element ).next( "span" )[ 0 ]){ + $( "" ).insertAfter( $( element ) ); + } + + + }, highlight: function ( element, errorClass, validClass ) { - $( element ).parents( ".col-sm-8" ).addClass( "has-error" ).removeClass( "has-success" ); - $( element ).next( "span" ).addClass( "glyphicon-remove" ).removeClass( "glyphicon-ok" ); + var esradio = $(element).prop("type") == "radio"; + var pariente; + if ( esradio ) { + pariente = $(element).parents(".form-group").children(".radioerror"); + pariente.addClass("has-error").removeClass("has-success"); + pariente.children( "span" ).addClass( "glyphicon-remove" ).removeClass( "glyphicon-ok" ); + } + else + $( element ).next( "span" ).addClass( "glyphicon-remove" ).removeClass( "glyphicon-ok" ); + $( element ).parents( ".input-container" ).addClass( "has-error" ).removeClass( "has-success" ); + }, unhighlight: function (element, errorClass, validClass) { - $( element ).parents( ".col-sm-8" ).addClass( "has-success" ).removeClass( "has-error" ); - $( element ).next( "span" ).addClass( "glyphicon-ok" ).removeClass( "glyphicon-remove" ); + var esradio = $(element).prop("type") == "radio"; + var pariente; + if ( esradio ) { + pariente = $(element).parents(".form-group").children(".radioerror"); + pariente.addClass("has-success").removeClass("has-error"); + pariente.children( "span" ).addClass( "glyphicon-ok" ).removeClass( "glyphicon-remove" ); + } + else + $( element ).next( "span" ).addClass( "glyphicon-ok" ).removeClass( "glyphicon-remove" ); + $( element ).parents( ".input-container" ).addClass( "has-success" ).removeClass( "has-error" ); + } }); diff --git a/registration.php b/registration.php index c08568f..6c3f3a1 100644 --- a/registration.php +++ b/registration.php @@ -10,21 +10,21 @@
-
+
-
+
-
+
@@ -32,7 +32,7 @@
-
+
@@ -40,14 +40,14 @@
-
+
-
+
@@ -57,7 +57,7 @@
-
+
@@ -65,13 +65,13 @@
-
+
-
+
@@ -80,7 +80,7 @@ -
+

@@ -90,32 +90,49 @@ we have submitted funding requests and hope to cover the housing for a shared room, but we cannot make a guarantee at this time -
+
+
+ +
+ +
-
-
- +
+
+ +
+
+ +
+
+
+ +
+ -
+
-
+
+
+
+
-
+
@@ -124,7 +141,7 @@
-
+