first name field 1 character


No avatar

2005-07-15 01:39

I seem to be having a problem with people who just want to enter only the first letter of their name instead of using the full name.
This results in the error please fill in all required fields.

How do I enable it to also check if there is only 1 character?


No avatar

2005-07-15 11:03

This is due to the checklength functio in libraries/Trash.php ...

function checkLength( $txt, $length = 3 ){
if( strlen( changeTxt( $txt, 'hBrSpace' ) ) > $length )
return true;
return false;
} // end function checkLength

which checks for the length being GREATER than the supplied argument, rather than treating the supplied argument as a minimum length.

You have a choice:
1) you can change the above function to test for greater-than-or-equal-to (change '.. > $length' to '.. >= $length'). I would'nt advise this because you would then have to check every single call to this function to make sure the passed parameters still work as intended.

2) (Recommended) In core/orders.php find the lines

function checkOrderFields( $aForm ){
checkLength( $aForm['sFirstName'], 1 )

and change to

function checkOrderFields( $aForm ){
checkLength( $aForm['sFirstName'], 0 )

I think this is actually classable as a bug - treewood, your opinion? - because the checkOrderFields function in the PHP code does not match the checks performed by the JavaScript code in checkForm.js. The script checks for length >= 1, whereas the php function checks for length > 1, for other fields besides first name! Not good!

treewood (OpenSolution)

Avatar: treewood

2005-07-15 12:37

wizzud - yes it is bug ... i fixed it in qc 0.3.1

Back to top
about us | contact