
09.05.2010, 21:57
|
|
Участник форума
Регистрация: 15.11.2006
Сообщений: 259
С нами:
10255414
Репутация:
151
|
|
Tesson,
Код:
<script>
function check_fields(el_id,el_id2)
{
if (document.getElementById(el_id).value == '' || document.getElementById(el_id2).value == '')
{alert('Заполнены не все поля!');return false;}
}
</script>
<form name="formesnd" method="post" action="sn.php" onsubmit="return check_fields('code','Message');">
<input type="text" name="code" id="code" size="35" class="text">
<textarea name="Message" id="Message" cols="34" rows="5" class="text"></textarea>
<input type="submit" name="button" id="button" class="ok" value="Отправить">
</form>
или
Код:
<script>
function check_fields(el_id,el_id2)
{
if (document.getElementById(el_id).value != '' && document.getElementById(el_id2).value != '')
{document.getElementById('button').disabled = false;}
else
{document.getElementById('button').disabled = true;}
}
</script>
<form name="formesnd" method="post" action="sn.php">
<input onkeyup="check_fields('code','Message');" type="text" name="code" id="code" size="35" class="text">
<textarea onkeyup="check_fields('code','Message');" name="Message" id="Message" cols="34" rows="5" class="text"></textarea>
<input type="submit" name="button" disabled="disabled" id="button" class="ok" value="Отправить">
</form>
В первом случае при нажатии "Отправить" вылезет alert и форма не отправится.
Во втором ты просто не сможешь нажать "Отправить" 
|
|
|