Forum Moderators: coopster

Message Too Old, No Replies

How to add error message as inserted message?

         

toplisek

6:22 pm on Mar 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I would like to style message box and how to bring message within javascript script and also style. Position of message should be above FORM. Currently it moves message as POP-UP window. I would like to show message above form as normal styled message box.

POP-UP has div.visibleNotifyMsg

and notifyErrors function is:
function notifyErrors(id, errors, visibleStateCSS) {
object = document.getElementById(id);
object.innerHTML = '<div class=clear></div><div class="floatleft" style="padding-left: 40px;padding-top: 30px;">Please change your errors<ul class="msgerror">';
object.innerHTML += errors.join("\n");
object.innerHTML += '</ul></div><div class=clear></div>';
object.className = visibleStateCSS;
} and

if(errStack.length > 0)
{
notifyErrors('notifyPopup', errStack, 'visibleNotifyMsg');
return false;
}

if(!frm.email.value.match(emailRegex))
{
errStack.push("<li>E-mail is not valid!</li>");
frm.email.focus();
}

On form is at the end:
<div id="notifyPopup" class="hiddenState" align="center"></div>

penders

6:45 pm on Mar 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This looks like a CSS query as opposed to PHP? You probably need to alter your CSS for #notifyPopup to change it from looking like a popup window to making it look more inline. You'll probably need to move your DIV to above your form in your HTML also.

Try the CSS forum:
[webmasterworld.com...]

MichaelBluejay

6:50 pm on Mar 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Well, this looks like a CSS problem not a PHP problem, so you probably want to post this in the CSS forum if you don't get an answer here. But I don't see anything in your code that would cause a popup window anyway. I think maybe the message is *layered* on top of your page, but not in a separate window, but even so I don't see any code that would cause a layered message. Anyway, try taking out the class="floatleft". And move the <div id="notifyPopup"></div> to be above your form.

[edited by: MichaelBluejay at 6:52 pm (utc) on Mar. 22, 2009]

MichaelBluejay

12:53 pm on Mar 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



When having problems like these it's helpful to try to write the smallest program you can to do what you want and build it from there. And if the smallest one you write doesn't work, then that's good to post here on WebmasterWorld because you'll get more and better help the easier it is for people to look through your code.

Here's the smallest code I can write to do what you're asking about:

<html> 

<script type=text/javascript>
function checkForm(email) {
pattern=/^[\w-]+[\w.-]*@[\w-]+[\w.-]*\.[\w-]{2,4}$/;
if (!pattern.test(email)) {
document.getElementById('error').innerHTML="That doesn't look like a valid email address.";
return false;
}
}
</script>

<div id=error></div>

<form action=script.pl method=post onsubmit="return checkForm(this.email.value)">
<p><input name=email>
<p><input type=submit value=Submit>
</form>
</html>