PHP Classes

if the java script is disabled the validation doesn't worth o...

Recommend this page to a friend!

      PHP Forms Class with HTML Generator and JavaScript Validation  >  All threads  >  if the java script is disabled the...  >  (Un) Subscribe thread alerts  
Subject:if the java script is disabled the...
Summary:Package rating comment
Messages:9
Author:Mat Patnik
Date:2009-01-26 20:56:29
Update:2009-01-27 20:49:25
 

Mat Patnik rated this package as follows:

Utility: Good
Consistency: Good
Documentation: Good
Examples: Good
Unit tests: Good
Tutorial videos: Good

  1. if the java script is disabled the...   Reply   Report abuse  
Picture of Mat Patnik Mat Patnik - 2009-01-26 20:56:29
if the java script is disabled the validation doesn't worth one penny!

  2. Re: if the java script is disabled the...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-01-26 21:25:58 - In reply to message 1 from Mat Patnik
The class can validate forms either on the browser side or on the server side. Just call the Validate function in your PHP script as you see in the examples.

  3. Re: if the java script is disabled the...   Reply   Report abuse  
Picture of Mat Patnik Mat Patnik - 2009-01-27 02:51:40 - In reply to message 2 from Manuel Lemos
Ok, I might jumped to the conclusion too quick but when I tell it to look at number from ex: 2 to 300 and it need to be an integer if I turn off java script it let me submit any form of characters.

I didn't find the Validate function in your examples can you point it out please.

I tried the ValidateOnlyOnServerSide but I still have to create something to validate it.

  4. Re: if the java script is disabled the...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-01-27 03:21:47 - In reply to message 3 from Mat Patnik
You need to specify in the definition of each field which validation rules you want to apply.

In your case you just need to set the "ValidateAsInteger" to 1, "ValidationLowerLimit" to 2 and "ValidationUpperLimit" to 300. That is similar to the validation of the age input of the test_form.php example.

  5. Re: if the java script is disabled the...   Reply   Report abuse  
Picture of Mat Patnik Mat Patnik - 2009-01-27 17:01:57 - In reply to message 4 from Manuel Lemos
I already did that but it doesn't valid on server side.

this is what I did:
$date = intval(date('Y'));
$form->AddInput(array(
"TYPE"=>"text",
"NAME"=>"birth",
"ID"=>"birth",
"ValidateAsInteger"=>1,
"ValidationLowerLimit"=>($date-65),
"ValidationUpperLimit"=>$date,
"ValidationErrorMessage"=>"It was not specified a valid date.",
"LABEL"=>"<u>Y</u>ear of birth",
"ACCESSKEY"=>"Y",
// I added this it just skip the java script
"ValidateOnlyOnServerSide"=>1
));

with or without the ValidateOnlyOnServerSide if I turn off the java script it let me sent any kind of character except tag, and quote.

I tried this too:
Year of birth: <fj45&80'sd;:1!235 vWE // integer only
Gender: male // dropdown list
Country: Canada // dropdown list

and the result is:
Array
(
[birth] => male
[country] => CA
)

so it did screw something in there

I'm using php 5.2 if that can help.

  6. Re: if the java script is disabled the...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-01-27 17:29:41 - In reply to message 5 from Mat Patnik
If you turn off Javascript, no browser side validation can happen.

The server side validation should always be performed using the class Validate function.

  7. Re: if the java script is disabled the...   Reply   Report abuse  
Picture of Mat Patnik Mat Patnik - 2009-01-27 18:07:54 - In reply to message 6 from Manuel Lemos
I agree but how do I do that?

I based my form from the test_form.php.
What am I missing?

  8. Re: if the java script is disabled the...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-01-27 18:49:10 - In reply to message 7 from Mat Patnik
I don't understand your difficulties. The test_form.php example demonstrates all you have to make it work with or without browser side Javascript validation.

When the form is submitted, you just need to check the results of the Validate() function to determine whether all fields are valid.

Take a look at the test_form.php example script and read the comments so you can understand the steps. You should also watch this tutorial video to understand all it should work.

phpclasses.org/browse/video/1/packa ...

  9. Re: if the java script is disabled the...   Reply   Report abuse  
Picture of Mat Patnik Mat Patnik - 2009-01-27 20:49:25 - In reply to message 8 from Manuel Lemos
My mistake :(

After looking character by character I find my error, I forgot to add $form->AddInputPart("doit"); at the end of the template.

I am so sorry of wasting your time :(

That will teach me lol

Now the form work perfectly
And it worth a lots of penny now ;)

Thank you very much for the class and support