Jump to:

23377 Posts in 18296 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » jquery validate failing...

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 416 Views
  • Futureweb
    Avatar
    Community Member
    232 Posts

    jquery validate failing... Link to this post

    Hi,

    I've followed the details here: http://www.ssbits.com/tutorials/2009/using-jquery-for-form-validation/
    but my form is being submitted no matter what I choose...

    unfortunately the default validation doesn't seem to work with tick boxes, so i'm having to cancel that and use a custom script

    the page is live here: http://gvnpods.org/become-a-member/signup

    can anyone see anything that might be stopping my jquery validation working?

    Cheers

  • martimiz
    Avatar
    Forum Moderator
    1068 Posts

    Re: jquery validate failing... Link to this post

    I think you should use the fieldname to define rules and messages, instead of the the field id:

    jQuery("#Form_SignupForm").validate({
       rules: {
          Form_SignupForm_Email: { required: true, email: true        },
          Form_SignupForm_LastName: { required: true },
          ...

    becomes

    jQuery("#Form_SignupForm").validate({
       rules: {
          Email: { required: true, email: true        },
          LastName: { required: true },
          ...

    Hope that helps...

  • Futureweb
    Avatar
    Community Member
    232 Posts

    Re: jquery validate failing... Link to this post

    Thanks, I'll give that a try tomorrow - late now!

    in the mean time I went back to the standard validation script and added this

    jQuery("#Form_SignupForm_TC").click(function(){
             
       // If checked
       if (jQuery("#Form_SignupForm_TC").is(":checked")){
          jQuery("#Form_SignupForm_Terms").val("yes")
       }else{
          Query("#Form_SignupForm_Terms").val("")
    }

    this crudely gets around the tick box issue by setting a value to a hidden field. silverstripe vaidlates the hidden field instead of the tickbox. the problem is that when you submit the form, you get the error messages. when you tick the box to correct the issue, the error message isn't being removed - it must be getting triggered by onkeydown or somthing...

    416 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.