Hi.
I was wondering if there's a way, using the server-side validation, to jump to / set focus on the error message that's returned?
atm i have:
to compare the two email fields (femail and cemail), and return that message.
However, if the form is below a bunch of text, then the error message is out of view when the page reloads due to the validation error. So is there a way of setting focus to that error message when the page loads?
cheers
I was wondering if there's a way, using the server-side validation, to jump to / set focus on the error message that's returned?
atm i have:
<?php
global $mainframe;
if ( JRequest::getVar('femail') != JRequest::getVar('cemail') )
return 'Sorry, your email addresses do not match, please check again as this is the only way we have of contacting you!';
?>
to compare the two email fields (femail and cemail), and return that message.
However, if the form is below a bunch of text, then the error message is out of view when the page reloads due to the validation error. So is there a way of setting focus to that error message when the page loads?
cheers
Hi schnitz123,
Hmmm . . . I don't believe that anything is passed back* to identify the input where the error is :-(
I guess one answer would be to add code here to add a value to the User session and then check for that in the Form HTML . . . and then use code similar to the other thread you have open.
and in the Form HTML
Bob
* From memory I think that CFv4 solves this problem.
Hmmm . . . I don't believe that anything is passed back* to identify the input where the error is :-(
I guess one answer would be to add code here to add a value to the User session and then check for that in the Form HTML . . . and then use code similar to the other thread you have open.
<?php
global $mainframe;
$session =& JFactory::getSession();
if ( JRequest::getVar('femail') != JRequest::getVar('cemail') ) {
$session->set('cf_error', 'femail');
return 'Sorry, your email addresses do not match, please check again as this is the only way we have of contacting you!';
} else {
$session->clear('cf_error');
}
?>
and in the Form HTML
<?php
$session =& JFactory::getSession();
$cf_error = $session->get('cf_error');
if ( $cf_error ) {
. . .
}
?>
NB Not tested and will need debugging and developing.Bob
* From memory I think that CFv4 solves this problem.
This topic is locked and no more replies can be posted.