Form submission not work with jqueryvalidation

23 replies · opened May 11, 2023

GgooddevMay 11, 2023

my form like the picture and my validate script is below
//Validation

jQuery(document).ready(function () {

jQuery.extend(jQuery.validator.messages, {
required: "กรุณาใส่ข้อมูล.",
remote: "Please fix this field.",
email: "Please enter a valid email address.",
url: "Please enter a valid URL.",
date: "Please enter a valid date.",
dateISO: "Please enter a valid date (ISO).",
number: "Please enter a number only.",
digits: "Please enter only digits.",
equalTo: "Please enter the same value again.",
accept: "Please enter a value with a valid extension.",
maxlength: jQuery.validator.format("ใส่ขั้นต่ำ {0} ตัว."),
minlength: jQuery.validator.format("ใส่มากสุดได้ {0} ตัว."),
rangelength: jQuery.validator.format("Please enter a value between {0} and {1} characters long."),
range: jQuery.validator.format("Please enter a value between {0} and {1}."),
max: jQuery.validator.format("Please enter a value less than or equal to {0}."),
min: jQuery.validator.format("Please enter a value greater than or equal to {0}."),
});

$.validator.setDefaults({
ignore: [],
});

var form = $("#formRegister");
form.each(function () {
var elem = $(this);
elem.validate({
errorClass: "is-invalid",
validClass: "is-valid",
errorElement: "div",
focusInvalid: true,
messages: {
payerUser: {
remote: "มีชื่อ ID นี้ในระบบแล้วลองใช้ชื่อใหม่",
minlength: "ใส่ขั้นต่ำ {0} ตัวอักษรขึ้นไป"
},
payerPasswordConfirm: {
equalTo: "ใส่ให้เหมือนกับ ช่องรหัสผ่าน"
}
},
rules: {
payerUser: {
required: true,
minlength: 4,
remote: {
url: "/auth/ajaxCheckRegisterEmail",
type: "POST",
dataType: "json",
data: "payer_email=" + $("#payerUser").val(),
dataFilter: function (data) {
//console.log(data);
//var json = JSON.parse(data);
return data.success;
},
beforeSend: function (xhr, opts) {
//console.log( $('#payerEmail').val());
//console.log( opts );
opts.data = "payer_email=" + $("#payerUser").val();
},
},
},
payerName: { required: true },
payerPassword: {
required: true,
minlength: 6,
maxlength: 12
},
payerPasswordConfirm: {
required: true,
equalTo: "#payerPassword",
},

    code: {
      required: true,
    },
  },
  errorPlacement: function (error, element) {
    element.parent().append(error);
    $("#btnReg").html("ลงทะเบียน");
  },
  invalidHandler: function (elem, validator) {
    $("html, body").stop(true, false).animate({
      scrollTop: $(validator.errorList[0].element).offset().top - 200
    }, 1500, "easeInOutExpo");
    $("#btnReg").html("ลงทะเบียน");
  },
  submitHandler: function(form) {
    jQuery('input,textarea,select', form).attr('readonly', 'readonly');
    console.log("pass");
    //$(form).submit();
    return true;

  }
});

});
});

SSemicolon WebSTAFFMay 12, 2023

Hello,

Since you are using a completely customized form validation codes, we recommend using the .customjs Class on the .form-widget Element to disable the Default Form functionalities included with Canvas.

From there you can easily extend the Forms based on your requirements. Additionally, we have different ways of displaying Form Data on the Page with AJAX if you still plan to use our AJAX Capabilities: https://docs.semicolonweb.com/docs/forms/alerts/ .

Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

GgooddevMay 12, 2023

I do like you suggestion and it not work . the result the same before.
I can send you ftp and you can see my coding on our server.

SSemicolon WebSTAFFMay 12, 2023

Hello,

Based on the Screenshot attached, this should work fine. Please provide us with a Live URL with the codes so that we can check out the exact issue and provide you with more accurate assistance on this. Thanks for your Patience.

Meanwhile, do let us know if we can help you with anything else or if you find any further issues with Canvas.

GgooddevMay 12, 2023

Live url is https://dekdd.com on home page form to submit member.

Thank you

SSemicolon WebSTAFFMay 12, 2023

Hello,

There are some JS Conflicts on the Page which is causing this issue. Consider enclosing all your Custom jQuery Codes inside the custom.js File inside this code:
[ch_pre type="js"](function ($) {

// Write your jQuery Codes here
// $(document).ready() etc. or Plugin Initializations

})(jQuery);[/ch_pre]

This should fix the issue but if you face further issues we can check further. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

GgooddevMay 12, 2023

I already put like you suggestion but I still can not submit the form. I use the validate script form your /js/plugins.form.js and not include from another location js.
I upload the code to live server already.

Thank you
art

SSemicolon WebSTAFFMay 12, 2023

Hello,

Please provide us with your FTP Details and we will look into this for you. Thanks for your Patience.

Meanwhile, do let us know if we can help you with anything else or if you find any further issues with Canvas. Thanks. :)

GgooddevMay 12, 2023

File of your theme location: /assets/fastweb/*
/assets/fastweb/js/custom.js -> script to use validate
Work file have 3 main file
/modules/frontend/controllers/Frontend.php
/modules/frontend/views/page_home.php
/modules/frontend/views/fastweb/meta_footer.php -> to load js file

SSemicolon WebSTAFFMay 12, 2023

Hello,

Fixed. The issue was due to Customizations. Please note that Canvas is not made for CodeIgniter by default and you will need to make custom changes in order to make them work. We have tweaked the codes a bit according to your needs. You can check the Changed Files: custom.js, meta_footer.js, meta_header.js, functions.js and page_home.php .

Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

GgooddevMay 13, 2023

Hi,

I see the code and check on the website. it still not submit the form when I put all the field but when I delete data some field it's work and the validate not true. It like if validate not correct because I validate all field before submit.

Hope you helps again please!
Cheers :)

SSemicolon WebSTAFFMay 13, 2023

Hello,

This issue is not related to Canvas Template anymore as the Form Functionality has already been disabled and all the JS Plugins now work as expected. Please provide us a Screenshot of the error generating from the Canvas Template and we can definitely help you further for this. Please consider checking our Support Policy: https://support.semicolonweb.com/support-policy/ to see whats included with Support. We assure you that if there are any further issues related to the Canvas JS Codes integrating with your CodeIgniter, we will definitely try to point you in the right direction but for any further Customization issues, you will need to Hire us to help you out with them so that we can properly debug the issues for you and fix them. If you are interested in Customizations, you can consider contacting us here: support@semicolonweb.com .

Thanks for Understanding.

Do let us know if we can help you with anything else or if you find any further issues with Canvas.

GgooddevMay 13, 2023

ok , I'll fix by myself or move back to POLO template
thank you
Art

SSemicolon WebSTAFFMay 13, 2023

Hello,

Sure. Please do let us know if you face any further issues with Canvas.

Have a Wonderful Weekend.

SSemicolon WebSTAFFMay 13, 2023

Hello,

Can you update the Codes online on your Website once again so that we can check this again and see if this can be fixed without many codes changes? Thanks for your Patience.

Meanwhile, do let us know if we can help you with anything else or if you find any further issues with Canvas.

GgooddevMay 13, 2023

Hello,

Thank you on your help, I open and you can upload file on you have overwrite again cause I upload the old before you change to it.

thank you,
Art

GgooddevMay 13, 2023

Hello,

I see this error when I delete some data field in image attachment, hope it will help you solve this

SSemicolon WebSTAFFMay 13, 2023

Hello,

These are the lines of code causing the issues, we have commented these lines and everything seems to be working fine now:
[ch_pre type="js"]remote: {
url: "/auth/ajaxCheckRegisterEmail",
type: "POST",
dataType: "json",
data: "payer_email=" + $("#payerUser").val(),
dataFilter: function (data) {
//console.log(data);
//var json = JSON.parse(data);
return data.success;
},
beforeSend: function (xhr, opts) {
//console.log( $('#payerEmail').val());
//console.log( opts );
opts.data = "payer_email=" + $("#payerUser").val();
},
},[/ch_pre]

So, it is certain that it is your Customizations that are causing the issues! :) Consider checking this Code.

Let us know if you need any further help! :)

PS. As you mentioned Polo, let us clarify, that it has been copied illegally from Canvas. So we highly request you to Support only Template Authors who do Original Work.

Additionally, I would like to mention, that we LOVE Chiang Mai and I used to stay in Huay Kaew Rd. at Hillside 4 and Palm Springs Condo and often go to CAMP at MAYA to do some work. Know a lot of Chiang Mai as I have stayed around 2 years in the city. Love Thailand and Thai people are the best! Would love to meet you guys when I come to Chiang Mai soon. :)

GgooddevMay 13, 2023

Hello,

Thank you for your support ,
This project my customers need to check the user have same in the system or not also. That why I use remote validate or you have and document to let me using Canvas validate like email, max length, min length or equalTo mean like option of the validate script you use in plugins.form.js can do? I see inside have jQuery Validation Plugin loading.

PS: Give me explain about Polo template. I buy Polo and use it before move to Canvas. I mean if it will take me time to fix this problem I'll make new site using POLO only not merge or get your Canvas to it.

For Chiang Mai Thailand, Do you living here 2 years? nice man.. Chiang Mai guy like me find opportunity to work in US or Australia hahaha.. If you back to living here let me know , we'll meet and go hang out :)

GgooddevMay 13, 2023

Hello,

I found how to fix it now. I will downgrade to 6.6.5 that version I can fix it and work fine with validate script.

Thank you so much with you help in a couple days :)

See you in Chiang Mai , Thailand.. :)

Art

SSemicolon WebSTAFFMay 13, 2023

Hello,

So glad the issues were resolved! We would sill recommend using Canvas 7. Simply replace the js/functions.js you have using in the meta_footer.php to this code:
[ch_pre]
[/ch_pre]

This will Load the JS like the v6.6.5 style. Additionally, we are working on a more flexible JS Version which we are planning to release next week which will make customizing the Plugins easier. Consider trying first with the Codes above and we are sure this will work fine with your existing codes if it works fine with the 6.6.5 codes.

Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

PS. Polo has been originally copied from Canvas and we have already complained to ThemeForest regarding this and they removed Polo from their Marketplaces, but they have come back after making just 10% changes to their codes but 90% of their codes are still copied from Canvas. If you compare, you will understand. But ThemeForest do not take any further action. :/

Anyways, Yes, Chiang Mai is one of the Best Cities in the World, except during February to April (when there is smoke). USA, Australia just look good from the outside man! Its not that great. But yes, would be amazing meeting you guys! :) Will definitely let you know when I am there.

Khob Khun Krub,
Rohit.

GgooddevMay 13, 2023

Hi Rohit,

Khob khun krub for help :)

PS: Sorry about POLO I'll use Canvas for the future customers :)

USA and Australia I think the currency rate exchange and job is focus on the positioning, Most Thai company is put all things to the one develop man hahaha..

Hope fully try Canvas 7 and I'll try to fix on version 7 next launching and cheers :)

Khob Khun Kub
Art

SSemicolon WebSTAFFMay 14, 2023

Sawasdee Kub,

Thanks So much once again Art, we really appreciate this.

Yes, agreed. USA and other Western Countries focus on Growth, but earn the money and come back to Thailand and invest. In future Thailand will be real world power! :)

Thanks again so much for your continued Support and please let us know if we can assist you with anything, small or big issues with your Website, we are always here for you.

Have a Great Sunday! :)

Khob Khun Kub,
Rohit.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard