You can create your own validate method:
http://docs.jquery.com/Plugins/Validation/Validator/addMethod#namemethodmessage

jQuery.validator.addMethod("digitsAndLineBreak", function(value, element) {
    return /^[\d|\n]+$/.test(value);
}, "Please enter only digits");

then:

$("#quicksend_form").validate({
    rules: {
        recepients: {
            required: true,
            digitsAndLineBreak: true,
            minlength: 10
        }
    }
});

On Thu, Oct 15, 2009 at 15:57, Renie <renie.ra...@gmail.com> wrote:

>
> I'm using the Jquery Validation Plugin on my site, and I have a
> textfield that validates to only allow numbers. However, that also
> doesn't allow linebreaks - which I need to have! Is there a way around
> this?
>
> Here's the working code:
>
>
> <html>
> <head>
> <script src="http://code.jquery.com/jquery-latest.js";></script>
> <script type="text/javascript" src="http://dev.jquery.com/view/trunk/
> plugins/validate/jquery.validate.js<http://dev.jquery.com/view/trunk/%0Aplugins/validate/jquery.validate.js>
> "></script>
> <script>
> $(document).ready(function() { // Doc Ready Functions
>
> $("#quicksend_form").validate({
>        rules: {
>                recepients: {
>                  required: true,
>                  digits: true,
>                  minlength: 10
>                }
>        }
> });
>
> }); // Doc Ready Functions
> </script>
>
> </head>
>
> <body>
>
> <form action="#" method="post" enctype="multipart/form-data"
> name="quicksend_form" id="quicksend_form">
> <textarea name="recepients" id="recepients" rows="20"></textarea>
> <input type="submit" name="button" id="button" value="Submit" />
> </form>
>
> </body
> </html>
>

Reply via email to