Welcome Guest, Not a member yet? Register   Sign In
Validation - prevent html
#1

Hi,

i want to prevent the user from input html in a contact form. The alpha_numeric_punct has no questionmark (?) or slash (/). Can we add this character by extending a rule or is there another way to prevent html? I know i can write a custom rule, but if there is a feature in ci i would use it.
Reply
#2

Yes you can extend the Validation Class.

CodeIgniter 4 User Guide - Creating Custom Rules

You could copy this method ( alpha_numeric_punct ) and work from that.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(10-09-2022, 12:29 AM)InsiteFX Wrote: Yes you can extend the Validation Class.

CodeIgniter 4 User Guide - Creating Custom Rules

You could copy this method ( alpha_numeric_punct ) and work from that.

Thank you.
Do i have to copy the method? I thought i could use the existing functionality and only add my extension. If the method will be updated later i don't have to copy the method again.

I still have a second question: Do some rules depend on the language? I took the alpha Rule, but if i input a czech name like Tomáš the rule fails and i got an error message in my form. I think it is caused by the carachters áš
Reply
#4

You can add your own, I just mentioned it so that you had something to go by.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB