Advertisement:

Author Topic: Custom field - how to allow user use only number (miles for car) ?  (Read 682 times)

safeacid

  • Jr. Member
  • **
  • Posts: 65
hello I have few questions.

1. How to allow users to use only numbers in custom field during posting an ad
2. how to show create two boxes for miles in search menu to look miles FROM .....  TO .....

?

thanks

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Custom field - how to allow user use only number (miles for car) ?
« Reply #1 on: January 15, 2018, 11:37:36 pm »
Hi.
For the second question look here:
https://forums.osclass.org/development/new-type-of-custom-field-suggestion-number-input-and-interval-filter/msg159215/#msg159215

This is not imposing the user to insert numbers in the input fields as the db column is text not numeric.

safeacid

  • Jr. Member
  • **
  • Posts: 65
Re: Custom field - how to allow user use only number (miles for car) ?
« Reply #2 on: January 16, 2018, 12:02:28 am »
Thanks i will look.

what about this at least?
<input id="number" type="number">


I don't know how to implement
 each custom fields have have Identifier name how can I test during posting an ad  ?

if custom fields field Identifier name  == "..."  {<input id="number" type="number">}

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Custom field - how to allow user use only number (miles for car) ?
« Reply #3 on: January 16, 2018, 12:59:02 am »
I never tested via type="number" because the field in DB is text so...
Anyway my solution workes ok. If the user inputs a nonnumeric value he loses, "author" or "seeker".

safeacid

  • Jr. Member
  • **
  • Posts: 65
Re: Custom field - how to allow user use only number (miles for car) ?
« Reply #4 on: January 16, 2018, 02:07:42 am »
with custom fields enhancer plugin I got this error in item php

Warning: array_key_exists(): The first argument should be either a string or an integer in /Applications/AMPPS/www/new/oc-content/plugins/custom_field_enhancer/functions.php on line 913


when I had applied your code for item no2

any way thanks for sharing.

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Custom field - how to allow user use only number (miles for car) ?
« Reply #5 on: January 16, 2018, 02:15:26 am »
 My solution is a core code changer.... it ads a new type of custom field... so I gues it's not compatible with the plugins for custom fields.
EDIT
Try to use date interval as a custom field and see if the same warning occurs.
It's a warning not error, and that plugin is a paid one so you can't share the code.... maybe the developer could help you.
« Last Edit: January 16, 2018, 02:26:08 am by marius-ciclistu »