This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

jameskhw2957
jameskhw2957

Hi,

I am trying to validate a field to accept only numeric, but it seemed like the validator has skipped the checking. Even i input characters such as "abc", the system won't prompt me any error message but it instead convert the value "abc" to 0.

May i know is this correct?

Thanks

herzgarlan22551
herzgarlan22551

Hi James,

Try to use 'regex:/[^0-9]/' instead, then you may need to customize your message as well.

Pat Och
Pat Och

hi,

you can find temporary solution here (before issue fix)

https://github.com/octobercms/october/issues/2311

just add this in your concerned model

public function afterValidate()

{

        if (!is_numeric(post('something')) ) {

            throw new \ValidationException(['something' => \Lang::get('system::validation.numeric', ['attribute' => \Lang::get('xx.xxx::lang.xx.xx')])]);

        }

}

Last updated

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.