Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

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

Userforms and email validation


Reply


3 Posts   1082 Views

Avatar
classicalbass

Community Member, 2 Posts

27 February 2011 at 6:50am

This is my first Silverstripe project and so far so good. I've managed to get three different jquery routines to work in my application, (two menus and one image display.)

I am attempting to implement the userforms module but I can't get the jquery email address validation to work.
I can see the jquery.validate.js file is where it should be and everything else works, but I can put garbage of any kind in the email field and it passes successfully.
I've pasted the relevant code from "view page source" below, just to verify that the jquery routine is there.
Is there something I'm missing?

<script type="text/javascript" src="http://mydomain.com/sapphire/thirdparty/jquery/jquery.js?m=1292911507"></script><script type="text/javascript" src="http://mydomain.com/userforms/thirdparty/jquery-validate/jquery.validate.min.js?m=1298687018"></script><script type="text/javascript">//<![CDATA[
         (function($) {
            $(document).ready(function() {
               $("#Form_Form").validate({
                  errorClass: "required",   
                  messages:
                     {
EditableTextField1:"Please enter your name.", EditableTextField2:"Test error message."
}
                  ,
                  rules:
                      {
EditableTextField1:{
required:1, minlength:"2", maxlength:"45"
}
, EditableTextField2:{
required:1
}

}
               });
            });
         })(jQuery);

//]]></script><script type="text/javascript">//<![CDATA[
         (function($) {
            $(document).ready(function() {
               
               
            })
         })(jQuery);

//]]></script>

Avatar
Willr

Forum Moderator, 5513 Posts

27 February 2011 at 4:15pm

Have you used an "Email Field" in the UDF? Looking at the jQuery you only have text fields (which don't have any email validation). "EditableTextField2" should be "EditableEmailField2" and should have an option email: true to trigger the validation.

Avatar
classicalbass

Community Member, 2 Posts

27 February 2011 at 4:34pm

Oh, good grief! I thought I had double checked that. Such a simple thing and that's what the problem was. (What a way to introduce myself to this forum. :( )

Thanks for a quick response.