Yes, im using Jquery validation, but im still trying to translate
this old onClick button to call plugin validate? How can i do
that using the same button? I need to use the same button
cause this button is part of a toolbar.

http://bassistance.de/jquery-plugins/jquery-plugin-validation/


                        <script type="text/javascript">


                                $().ready(function() {

                                        // add * to required field labels
                                        $("div.required 
label").append("&nbsp;<strong><font color=\"#FF0000\">*</font></strong>&nbsp;");

                                        
jQuery.validator.addMethod("specialAlphaNumeric", function( value, element ) {
                                                var result = 
this.optional(element) || value.length >= 2 && /^([A-Z0-9áéíóúüçìñ.,'_\- 
]+)$/i.test(value);
                                                if (!result) {
                                                        //element.value = "";
                                                        var validator = this;
                                                        setTimeout(function() {
                                                                
validator.blockFocusCleanup = true;
                                                                element.focus();
                                                                
validator.blockFocusCleanup = false;
                                                        }, 1);
                                                }
                                                return result;
                                        }, "Puede contener espacios, tener al 
menos dos y cualquiera de los siguientes carácteres: 
[a-z][0-9][áéíóúüçìñ.,'_-]");

                                        
jQuery.validator.addMethod("alphaNumeric", function( value, element ) {
                                                var result = 
this.optional(element) || value.length >= 2 && 
/^[A-Z]([A-Z0-9]+)$/i.test(value);
                                                if (!result) {
                                                        //element.value = "";
                                                        var validator = this;
                                                        setTimeout(function() {
                                                                
validator.blockFocusCleanup = true;
                                                                element.focus();
                                                                
validator.blockFocusCleanup = false;
                                                        }, 1);
                                                }
                                                return result;
                                        }, "Debe empezar con una letra, tener 
al menos dos y cualquiera de los siguientes carácteres: [a-z][0-9]");

                                        $("#UserRegisterForm").validate({

                                                // the errorPlacement has to 
take the table layout into account
                                                errorPlacement: function(error, 
element) {
                                                        if ( 
element.is(":radio") )
                                                                error.appendTo( 
element.parent().next().next() );
                                                        else if ( 
element.is(":checkbox") )
                                                                error.appendTo 
( element.next() );
                                                        else
                                                                error.appendTo( 
element.parent().next() );
                                                },
                                                // specifying a submitHandler 
prevents the default submit, good for the demo
                                                submitHandler: function() {
                                                        alert("submitted!");
                                                },
                                                // set this class to 
error-labels to indicate valid fields
                                                success: function(label) {
                                                        // set &nbsp; as text 
for IE
                                                        
label.html("&nbsp;").addClass("checked");
                                                }

                                        });

                                });

                        </script>


Reply via email to