[Solved] Server Side Validation question

SilentCid 24 May, 2011
I am not sure what I am looking for to make this not case sensitive. I have this text field where the user needs to type the word "Yes" in the box. If they type the word "yes" in lower case it will give them the flag. I would like them not worry about case sensitivity. Here is my code


<?php
if(JRequest::getVar('activity_level_agreement') != 'Yes')
return 'Sorry, failed to enter proper word in the Activity Agreement. Please enter the correct word.';
?>


Would it be something like this?

 if(JRequest::getVar('activity_level_agreement') != 'Yes' !='yes')
return 'Sorry, failed to enter proper word in the Activity Agreement. Please enter the correct word.';
?>
GreyHead 24 May, 2011
Hi silentcid,

Please try
<?php
$ala = JRequest::getVar('activity_level_agreement', '', 'post');
if ( strtolower($ala) != 'yes') {
  return 'Sorry, failed to enter proper word in the Activity Agreement. Please enter the correct word.';
}
?>

Bpb
SilentCid 24 May, 2011
Hello Bob,

Thanks for the quick reply and your code works. I guess my assumption on what the code should of look was way off so I guess I'll have to hit up the text books again.
GreyHead 24 May, 2011
Hi silentcid,

You were pretty close; you can't use JRequest inside an if() condition so I put that on an earlier lie; then strtolower() is the PHP function to force the result into lower case.

Bob
This topic is locked and no more replies can be posted.