@@ -1,7 +1,19 @@
+
+
+function captchaProcess( form ) {
+ var id = $(form).find( 'textarea[name=g-recaptcha-response]' )
+ .attr( 'id' ).match( /\d+$/ );
+ if( id ){ id = id[0] } else { id = 0 }
+ grecaptcha.reset( Number( id ) );
+ grecaptcha.execute( Number( id ) );
+ // When .execute is done this will trigger callback
+ // which is specified on g-recaptcha div element via data-callback attr
+}
+
+
// FORM VALIDATION
-var validator;
$(function(){
- validator = $('#contact_us-form').validate({
+ $('#contact_us-form').validate({
rules: {
name: {
required: true,
Unstage this hunk [y,n,q,a,d,j,J,g,/,s,e,?]? s
Split into 3 hunks.
@@ -1 +1,14 @@
+
+
+function captchaProcess( form ) {
+ var id = $(form).find( 'textarea[name=g-recaptcha-response]' )
+ .attr( 'id' ).match( /\d+$/ );
+ if( id ){ id = id[0] } else { id = 0 }
+ grecaptcha.reset( Number( id ) );
+ grecaptcha.execute( Number( id ) );
+ // When .execute is done this will trigger callback
+ // which is specified on g-recaptcha div element via data-callback attr
+}
+
+
// FORM VALIDATION
Unstage this hunk [y,n,q,a,d,j,J,g,/,e,?]? n
@@ -1,3 +14,2 @@
// FORM VALIDATION
-var validator;
$(function(){
Unstage this hunk [y,n,q,a,d,K,j,J,g,/,e,?]? y
@@ -3,5 +15,5 @@
$(function(){
- validator = $('#contact_us-form').validate({
+ $('#contact_us-form').validate({
rules: {
name: {
required: true,
Unstage this hunk [y,n,q,a,d,K,j,J,g,/,e,?]? y
@@ -47,12 +59,7 @@ $(function(){
$(element).removeClass("error_inp");
},
submitHandler: function(form) {
- var id = $(form).find( 'textarea[name=g-recaptcha-response]' )
- .attr( 'id' ).match( /\d+$/ );
- if( id ){ id = id[0] } else { id = 0 }
- grecaptcha.execute( Number( id ) );
- // When .execute is done this will trigger callback
- // which is specified on g-recaptcha div element via data-callback attr
+ captchaProcess( form );
}
});
});
Unstage this hunk [y,n,q,a,d,K,g,/,e,?]? n
error: patch failed: public/v2/js/contact_us.js:1
error: public/v2/js/contact_us.js: patch does not apply
@@ -1,7 +1,6 @@
// FORM VALIDATION
-var validator;
$(function(){
- validator = $('#contact_us-form').validate({
+ $('#contact_us-form').validate({
rules: {
name: {
required: true,
DETAILS:
git diff -b -w --ignore-blank-lines /home/kes/s/public/v2/js/contact_us.js
@@ -1,10 +1,24 @@
+function show_validator_errors( xhr, validator ) {
+ if( xhr.status == 404 ) { return }
+
+ var res = xhr.responseJSON;
+ // TODO: Display responseText if there is no responseJSON
+ if( !res ) { return };
+
+ var errors = {};
+ // convert server response into validator format
+ for( var error in res.error.info ) {
+ errors[error] = res.error.info[ error ][ 1 ] || 'Error';
+ }
+ validator.showErrors( errors );
+}
+
function captchaProcess( form ) {
var id = $(form).find( 'textarea[name=g-recaptcha-response]' )
.attr( 'id' ).match( /\d+$/ );
if( id ){ id = id[0] } else { id = 0 }
- grecaptcha.reset( Number( id ) );
grecaptcha.execute( Number( id ) );
// When .execute is done this will trigger callback
// which is specified on g-recaptcha div element via data-callback attr
git diff -b -w --ignore-blank-lines --staged /home/kes/s/public/v2/js/contact_us.js
@@ -1,7 +1,19 @@
+
+
+function captchaProcess( form ) {
+ var id = $(form).find( 'textarea[name=g-recaptcha-response]' )
+ .attr( 'id' ).match( /\d+$/ );
+ if( id ){ id = id[0] } else { id = 0 }
+ grecaptcha.reset( Number( id ) );
+ grecaptcha.execute( Number( id ) );
+ // When .execute is done this will trigger callback
+ // which is specified on g-recaptcha div element via data-callback attr
+}
+
+
// FORM VALIDATION
-var validator;
$(function(){
- validator = $('#contact_us-form').validate({
+ $('#contact_us-form').validate({
rules: {
name: {
required: true,