Function question- ASAP

Discussion in 'JavaScript' started by progfrog, Mar 30, 2008.

  1. #1
    hi guys!
    i am searching my mind for hours and do not understand why this thing doesn't work - it sepose to show erros if the email field in the form is empty buy it doesn't...

    PLEASE HELP ME!!
    and here it is:

    This is one function who call another function:



    Myfunc(){


    if (!validEmailValue){
    shows erros BOX///
    My_erros.innerHTML= "eMail adress IS INVALID";
    return false;
    }
    else
    {
    form1.submit();
    }
    return true;
    }



    function validEmailValue(){
    mailPass = form1.my_Email.value;
    if (mailPass==""){
    return false;
    }
     
    progfrog, Mar 30, 2008 IP
  2. Morishani

    Morishani Peon

    Messages:
    239
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    There you go :
    function Myfunc()
    	{
    	if (!validEmailValue())
    		{
    		//shows erros BOX
    		My_erros.innerHTML= "eMail adress IS INVALID";
    		return false;
    		}
    	else
    		{
    		form1.submit();
    		}
    	return true;
    	}
    
    function validEmailValue()
    	{
    	mailPass = form1.my_Email.value;
    	if (mailPass=="")
    		{
    		return false;
    		}
    	return true;
    	}
    Code (markup):
    And a better way :
    
    function Myfunc()
    	{
    	if (!validEmailValue())
    		{
    		My_erros.innerHTML= "eMail adress IS INVALID";
    		return false;
    		}
    	else
    		return true;
    	}
    
    function validEmailValue()
    	{
    	mailPass = form1.my_Email.value;
    	return (mailPass != "");
    	}
    
    Code (markup):
    and ofcourse you need to change the form onsubmit event to return Myfunc();

    Like this :
    <form onsubmit="return Myfunc();">
    HTML:
    Good luck :)
     
    Morishani, Mar 30, 2008 IP