1

I have small form :

Following is the script where I am validating the required field for input field which is working perfectly now I want to validate url using jquery.validate.min.js.

<script type="text/javascript" >
            $(document).ready(function() {                                                      
                var container = $('#error');                
                $("#rssform").validate({                            
                    errorContainer: container,
                    errorLabelContainer: $(container),
                    meta: "validate",
                    rules: {                                          
                        feedurl: {
                            required:true                         
                        }                        
                    },
                    messages: {                
                        feedurl: {
                            required:"Please Enter the URL"                            
                        }                                                
                    }

                });

            });
        </script>

<form action="rssindex.php" method="POST" id="rssform">
                    <label>Enter the feed URL&nbsp;</label>         
                    <input type="submit" name="submit" value="GO" id="submit"/>
                </form>                

How can I do this. Any solution? Thanks

1
  • adding class='url' to the input should do the trick. Commented Oct 6, 2012 at 10:13

1 Answer 1

1

jQuery validate plugin provide method to validate url.

Example:

$("#myform").validate({
  rules: {
    field: {
      required: true,
      url: true
    }
  }
});

For your code, add url: true to the rules.

                    feedurl: {
                        required:true,
                        url: true     //here                         
                    }                        
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.