• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validating form data

#2
[eluser]Mirge[/eluser]
[quote author="alvaroeesti" date="1348403148"]
Howdy!

I have got a couple of issues with my form:

1 ) It won't listen to the maxlength limit I write here, so regardless of how many characters someone enters, it does not complain (they could bufferoverflow my ap)

$this->form_validation->set_rules('areato', 'areato', 'trim|is_numeric|maxlength=[5]|xss_clean');

As you see it should allow a max of 5 characters, but it doesn't care.


2) The second issue is more difficult. In input type field boxes, I have written what the user should enter, (instead of putting a label by or above the field) Usually as you know, as you focus on the field, there is some javascript stuff that automatically deletes the message of say, "enter number". but that input type field is optional, so it can happen that someone just doesnt care about that parameter and leaves the default text message of "enter number".

What happens then? Since in my validation rules I wrote that only numeric characters are allowed, then it will detect the default message "enter number", will notice alfanumeric characters and will give the error.

So, the validation rules should know that it has to ignore that as it is not the user who wrote it, but the default instructions.
[/quote]

1.) Use the MAXLENGTH attribute for your input text field. See: http://www.w3schools.com/tags/att_input_maxlength.asp

Note that this isn't enough on its own, it's simply a usability feature. For form validation, use the rule max_length[5] (instead of max_length=[5]).

2.) You should use the PLACEHOLDER attribute (HTML 5) for your input text field. See: http://www.w3schools.com/html5/att_input...holder.asp


Messages In This Thread
Validating form data - by El Forum - 09-23-2012, 05:25 AM
Validating form data - by El Forum - 09-23-2012, 06:38 AM
Validating form data - by El Forum - 09-23-2012, 06:48 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.