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 7777459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:08:50+00:00 2026-06-01T18:08:50+00:00

I am building a form system and I have now started to work on

  • 0

I am building a form system and I have now started to work on the validation. My framework is CI so for the main part of my validation I have 'trim|required|htmlspecialchars' but what I was wanting to know:

A) What would be best to use for url and phone* inputs

B) What would you recommend that I use for client side validation – if any at all?

*I am from New Zealand so our phone numbers are 00 123 4567 or 1234567

  • 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-06-01T18:08:52+00:00Added an answer on June 1, 2026 at 6:08 pm

    CI’s validation is seriously shitty to deal with, especially when you want to make use of awesome jquery pluggins that make life simple.

    For client side, I make use of a jquery plugin written by Jörn Zaefferer, it is pretty easy to get the hang of and is very customizable.

    There are plenty of built in methods for standard things like urls, for NZ phone numbers I created some custom rules you can add to the additional-methods.js file that comes with the plugin.

    /**
     * matches NZ phone number formats
     * 
     * +64 7 123 1234
     * or
     * 07-123-1234
     * or
     * 071231234
     * 
     * spaces/hyphens optional
     *
     */
    jQuery.validator.addMethod('phoneNZ', function(phone_number, element) {
    return this.optional(element) || phone_number.length > 9 &&
    phone_number.match(/^(0|(\+64(\s|-)?)){1}\d{1}(\s|-)?\d{3}(\s|-)?\d{4}$/, 'Please specify a valid phone number');
    
    
    /**
     * matches NZ mobile number formats
     *  
     * 021 123 1234
     * or
     * 027 123 1234
     * or
     * 022-123-1234
     * or
     * +64 21 123 1234
     *
     * spaces/hyphens optional
     * 
     */
    jQuery.validator.addMethod('mobileNZ', function(phone_number, element) {
    return this.optional(element) || phone_number.length > 9 &&
    phone_number.match(/^(0|(\+64(\s|-)?)){1}(21|22|27){1}(\s|-)?\d{3}(\s|-)?\d{4}$/);
    }, 'Please specify a valid mobile number');
    

    As a side note, use these sparingly, unless you plan on dialing these numbers computationally just leave them as free text with a limit on length, there are a lot of variations on how people want to enter phone numbers and you’re better off not pissing people off by enforcing a rule that does not suit them / their number / addition of letters / + symbols / extentions etc

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

Sidebar

Related Questions

I'm building form validation controls for our C# ASP application. The bulk of the
I am building a form in Zend Framework 1.9 using subforms as well as
Suppose you're building an HTML form and you want to have 2 or more
I have a simple form on an ASP.NET MVC site that I'm building. This
i'm building a message system for a virtual community, but i can't take the
I have a page that is definitely not a form but I need to
A section of a site I am building needs some form of revision system
I'm building a small messaging system like you have in facebook. Only thing is
I'm building a voting system for calls, and have tried to build it in
I'm building this report in a system for a Billboard company. They have a

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.