Link to home
Start Free TrialLog in
Avatar of denny3d
denny3d

asked on

javascript validation form message into dialog jquery

Hello EE

i have a script javascript for validate a form with alert message.
My problem is:
how i change default alert windows with dialog jquery?

my code is:
function check_01() {
	
	errtxt = "";
	err = 0;
	
	
	//if (document.dgu.glass1.value == "seleziona" ||
	//if (document.dgu.tipology1.value == "seleziona") 	{ err = 1; errtxt += "- Prima Tipologia Vetro\n";	}
	if (document.dgu.glass1.value == "seleziona" || document.dgu.glass1.value == "") 		{ err = 1; errtxt += "- Primo Vetro\n";	}
	if (document.dgu.frame1.value == "seleziona") 		{ err = 1; errtxt += "- Primo Telaio\n";	}
	//if (document.dgu.tipology2.value == "seleziona") 	{ err = 1; errtxt += "- Seconda Tipologia Vetro\n";	}
	if (document.dgu.glass2.value == "seleziona") 		{ err = 1; errtxt += "- Secondo Vetro\n";	}
		
	if (document.dgu.tipology3.value != "seleziona" && (document.dgu.tipology2.value == "seleziona" || document.dgu.tipology1.value == "seleziona"))
	{ err = 1; errtxt += "- Secondo Vetro\n"; }
	
	if (document.dgu.tipology3.value != "seleziona" && document.dgu.frame2.value == "seleziona") { err = 1; errtxt += "- Secondo Telaio\n"; }
	
	if (document.dgu.frame2.value != "seleziona"
		&& document.dgu.tipology3.value == "seleziona") { err = 1; errtxt += "- Terzo Vetro\n"; }
	
	if (document.dgu.qty.value == "")		{ err = 1; errtxt += "- Quantita'\n";	}
	if (document.dgu.w.value == "")			{ err = 1; errtxt += "- Base\n";		}
	if (document.dgu.h.value == "")			{ err = 1; errtxt += "- Altezza\n";		}
	
	if (err) {
		alert("ATTENZIONE!\n\nDEVI inserire:\n"+errtxt);
	} else {
		document.dgu.submit();
	}
	
}

function check_02() {
	errtxt =

Open in new window

Avatar of kadaba
kadaba
Flag of India image

you could do this way.(without the dialog)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  
  <script>
  $(document).ready(function(){
    
    $("form").submit(function(){
	  var err = "";	
		$('#errorSpan').html("");
		$('#errorSpan').hide();
      if ($("#test1").val() == "") {
        err=err+"A cannot be empty<br>";
      }

      if ($("#test2").val() == "") {
        err=err+"B cannot be empty<br>";
      }
	if(err){
		$('#errorSpan').html(err);
		$('#errorSpan').show('slow');
		return false;
	}	
      return true;
    });

  });
  </script>
  <style>
  p { margin:0; color:blue; }
  div,p { margin-left:10px; }
  span { color:red; }
  </style>
</head>
<body>
  <span id="errorSpan" style="display:none"></span>
  <form action="javascript:alert('success!');">
    <div>
      A:<input id="test1" type="text" /><br>
	  B:<input id="test2" type="text" /><br>
	
      <input type="submit" value="submit"/>
    </div>
  </form>
</body>
</html>

Open in new window

Avatar of denny3d
denny3d

ASKER

Hi Kadaba

but i want use a dialog as alert windows or anything script.

regards
Denny
ASKER CERTIFIED SOLUTION
Avatar of kadaba
kadaba
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial