Jump to content

Validate Title Field to Allow Only Numbers


waheed
 Share

Recommended Posts

Hi, Coming from a background of WP I'm very new to PW (this is my very first project), but so far it has been very easy to learn. Currently I'm developing an intranet webapp to my school. I would like the "school grades" to be added as pages without any field in it, except "title" and "name". I would like the "title" to hold only numbers (optionally min:1 & max:10) and non-repeating (pages with same title cannot be added). Is this possible to be done, if so how? (Pls, try not to guide me towards a premium module, we run on a small budget)

Link to comment
Share on other sites

  On 6/24/2017 at 10:09 AM, fbg13 said:

On the edit page of the title field, go to input tab, open the pattern field, there you can add a regular expression pattern ( [-+]?[0-9]*[.,]?[0-9]+

Expand  

Thanks @fbg13.

But won't this affect the title field of other pages as well. 

  On 6/24/2017 at 10:09 AM, fbg13 said:

Or you can add a hook and check the title before saving. https://processwire.com/api/hooks/

Expand  

I think I'll go with hooks. It'll give me more control, I guess. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...