Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3792024
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:33:32+00:00 2026-05-19T12:33:32+00:00

I want to validate a form field for URL. I have set the default

  • 0

I want to validate a form field for URL. I have set the default for the field to http://. When the user doesn’t enter a URL, and leaves the http://, it says invalid URL. URL is not required, so if it’s only http://, it should not show error message. How can I make it ignore if the person submits http:// as the URL?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T12:33:32+00:00Added an answer on May 19, 2026 at 12:33 pm

    http:// is not a valid url, so if you want to allow it anyway there are 2 options

    1. create a custom validation rule, that returns true for a real url + http://
    2. use the before validate callback and set the url field to blank if it is just http://

    hope that helps

    EDIT

    I forgot: you don’t need to set required but 'allowEmpty' => true

    required -> the form must contain a field xyz that is send to the server

    allowEmpty-> a field may be blank


    I added the link to the callback function above, but anyway .. here it is:

    in your model class (I just suppose it’s User):

    class User extends AppModel {
        ..
    
        function beforeValidate() {
            if (isset($this->data['User']['url']) && $this->data['User']['url'] == 'http://') {
                $this->data['User']['url'] = '';
            }
            return true;
        }
        ..
    }
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to validate some of the field in my form. and I want
I want to validate a form where any field should not be blank. I
I am using jquery validation plugin to validate my form. I have one field
I want to validate just one field of a form. Here is my model:
I want to validate a form fields (text) input. It should only be a
Hi I want to validate a form input so it only takes the numbers
Im using asp.net webforms. c# I want to validate a form. In the codebehind
I want to validate a registration form that accepts an email address in the
I want to post some values from a simple HTML form, validate them with
I have a form that validates the email address and I want to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.