This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Replace error box with javascript alert
#1

Hi all,

The css box for displaying errors is just fine (ex: "Please enter your name"). I know this seems like a downgrade but how can I replace this with a javascript alert? For optimum site integration I would prefer this.

Managed so far this, in includes/app/processor.php:

if (empty($cmtx_name)) { //if name is empty

echo <<<EOD
<script src="my_javascript_custom_box_script.js"></script>
<link rel="stylesheet" href="my_custom_css_for_the_alert_box.css" />
<script>
jAlert('Please enter your name!', 'Mysite.com', function() {
$(document.getElementsByName('cmtx_name')).focus();
});

</script>
EOD;

return false;

Works, but the text entered by users in a input field is cleared when the alert pops up. I could fix this with sessionStorage, but I am sure other bugs will appear.

Is there a more elegant way to do this? Devs?

Thank you!
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by MattyP
11-Apr-2020, 08:08 PM
Last Post by CommiC
13-Aug-2012, 09:16 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)