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 3:09 PM, 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]+

Thanks @fbg13.

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

On 6/24/2017 at 3:09 PM, fbg13 said:

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

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

Link to comment
Share on other sites

3 hours ago, waheed said:

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

You can do it per template, by going to the template edit page and click the title field.

Everything you set there is gonna affect that template only.

  • Like 4
Link to comment
Share on other sites

1 hour ago, fbg13 said:

You can do it per template, by going to the template edit page and click the title field.

Everything you set there is gonna affect that template only.

I see, thanks.

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...