Change JS alert to DOM error message div

Posted by Jason on Stack Overflow See other posts from Stack Overflow or by Jason
Published on 2011-06-21T19:48:38Z Indexed on 2011/06/22 0:23 UTC
Read the original article Hit count: 491

Filed under:
|
|
|

I need to convert my error messaging to a positioned div (hidden initially) instead of the standard js alert. I realize I need to push the alert message to the DOM, but I'm new to javascript. Any help would be appreciated.

Additionally, I need to do it without a confirm (so error message removes on field focus)

if(el != null) {
                switch(el.name) {
                    case "firstName":              
                        //First Name Field Validation, Return false if field is empty
                        if( f.firstName.value == "" )
                        {
                            alert( bnadd_msg_002 );
                            if ((typeof TeaLeaf != "undefined") && (typeof TeaLeaf.Client != "undefined") && (typeof TeaLeaf.Client.tlAddEvent != "undefined") ) {
                                var nVO = { ErrorMessage : bnadd_msg_002} 
                                var subtype="CustomErrorMsg";
                                TeaLeaf.Event.tlAddCustomEvent(subtype, nVO);
                                    }
                            return false; 
                        }
                        break;

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about validation