Jump to content
php.lv forumi
  • 0

JS pārbaude


NBS

Question

Sveiki, man nezin kāpēc nestrādā šis kods:

 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>mmmm</title>

<script type="text/javascript">

function validate()
{
var darbalaiks = getElementById("darb_laiks").value;
if (darbalaiks == "")
{
	alert("Darba laiks ir atstāts tukšs!");
}
}

</script>

<form method="POST" action="a.htm" onsubmit="return validate();">
	<input type="text" id="darb_laiks" name="darb_laiks" value="" />
	<input type="submit" name="submit" value="OK" />
</form>
</html>

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Kā izpaužas nestrādāšana? Javaskript kļūda? Kāda?

Pirms getElementById nav jāliek priekšā document. ?

No validate() fjas derētu atgriezt arī boolean vērtību true vai false, jo tu tu izmanto return kontekstā.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...