mam formularz w ktorym sa 2 przyciski i 2 pola tekstowe chcialbym zeby niemzliwym bylo wyslanie formularza ktory nie zawieralby tekstu we wszystkich. Tyle mam:
<script language="javascript" type="text/javascript"> <!--
function verify(Form1)
{
for (i = 0; i < Form1.length; i++)
{
var field = Form1.elements[i];
if (field.type == "text" || field.type == "textarea" && field.value == "")
{
return false;
}
}
return true;
}
-->
<form name="Form1" method=post> <input type="text" name=NewText size=4 maxlength=4> <input type="button" value="Button1" name=button1 onClick="return check1();" /> <input type=\"text\" name=\"NewText1\"> <input type="button" value="Button2" name=button2 onClick="return check2();">
<script language=javascript TYPE="text/javascript"> <!--
function check1()
{ if (verify(Form1))
{
document.Form1.action = "http://anypage.com";
document.Form1.target = "_blank";
document.Form1.submit();
return true;}
else
{
alert("Please fill out all obligatory fields");
return false;
}
}
function check2()
{ if (verify(Form1))
{
document.Form1.action = "test.php";
document.Form1.target = "_blank";
document.Form1.submit();
return true; }
else
{
alert("Please fill out all obligatory fields");
return false;
}
}
i za kazdym razem jak wysylam dostaje alert ze pola sa nie wypelnione nie wazne czy sa czy nie? ktos wie moze gdzie jest blad o czym zapomnialem??