ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻡﺮﻓ ﯽﺠﻨﺳ ﺭﺎﺒﺘﻋﺍ


فهرست مطالب

    نمایش فهرست مطالب


ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻡﺮﻓ ﯽﺠﻨﺳ ﺭﺎﺒﺘﻋﺍ

.ﺩﺍﺩ ﻡﺎﺠﻧﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺎﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ HTML ﻡﺮﻓ ﯽﺠﻨﺳ ﺭﺎﺒﺘﻋﺍ

ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﻭ ﺪﻫﺩ ﯽﻣ ﺭﺍﺪﺸﻫ ﺍﺭ ﯽﻣﺎﯿﭘ ﻊﺑﺎﺗ ﻦﯾﺍ ،ﺪﺷﺎﺑ ﯽﻟﺎﺧ (fname) ﻡﺮﻓ ﺪﻠﯿﻓ ﮏﯾ ﺮﮔﺍ

ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻝﺎﺜﻣ

function validateForm() {
  let x = document.forms["myForm"]["fname"].value;
   
if (x == "") {
      alert("Name must be filled out");
      return false;
    }
}

:ﺩﺮﮐ ﯽﻧﺍﻮﺧﺍﺮﻓ ﺍﺭ ﻊﺑﺎﺗ ﻥﺍﻮﺗ ﯽﻣ ﻡﺮﻓ ﻝﺎﺳﺭﺍ ﻡﺎﮕﻨﻫ

HTML ﻡﺮﻓ ﻪﻧﻮﻤﻧ

<form name="myForm" action="/action_page.php" onsubmit="return validateForm()" 
method="post">
 Name: <input type="text" name="fname">
<input type="submit" value="Submit">
</form>

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<head>
<script>
function validateForm() {
  let x = document.forms["myForm"]["fname"].value;
  if (x == "") {
    alert("Name must be filled out");
    return false;
  }
}
</script>
</head>
<body>

<h2>JavaScript Validation</h2>

<form name="myForm" action="/action_page.php" onsubmit="return validateForm()" method="post">
  Name: <input type="text" name="fname">
  <input type="submit" value="Submit">
</form>

</body>
</html>

ﺪﻨﮐ ﺪﯿﯾﺄﺗ ﺍﺭ ﯼﺩﺪﻋ ﯼﺩﻭﺭﻭ ﺪﻧﺍﻮﺗ ﯽﻣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

:ﺩﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﯼﺩﺪﻋ ﯼﺩﻭﺭﻭ ﯽﺠﻨﺳ ﺭﺎﺒﺘﻋﺍ ﯼﺍﺮﺑ ﺐﻠﻏﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

ﺪﯿﻨﮐ ﺩﺭﺍﻭ 10 ﺎﺗ 1 ﻦﯿﺑ ﯼﺩﺪﻋ ﺎﻔﻄﻟ

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Validation</h2>

<p>Please input a number between 1 and 10:</p>

<input id="numb">

<button type="button" onclick="myFunction()">Submit</button>

<p id="demo"></p>

<script>
function myFunction() {
  // Get the value of the input field with id="numb"
  let x = document.getElementById("numb").value;
  // If x is Not a Number or less than one or greater than 10
  let text;
  if (isNaN(x) || x < 1 || x > 10) {
    text = "Input not valid";
  } else {
    text = "Input OK";
  }
  document.getElementById("demo").innerHTML = text;
}
</script>

</body>
</html> 


ﺭﺎﮐﺩﻮﺧ HTML ﻡﺮﻓ ﯽﺠﻨﺳ ﺭﺎﺒﺘﻋﺍ

:ﺩﺍﺩ ﻡﺎﺠﻧﺍ ﺮﮔﺭﻭﺮﻣ ﻂﺳﻮﺗ ﺭﺎﮐﺩﻮﺧ ﺭﻮﻃ ﻪﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ HTML ﻡﺮﻓ ﯽﺠﻨﺳ ﺭﺎﺒﺘﻋﺍ

.ﺪﻨﮐ ﯽﻣ ﯼﺮﯿﮔﻮﻠﺟ ﻡﺮﻓ ﻦﯾﺍ ﺩﻮﺟﻭ ﺯﺍ ﯼﺯﺎﯿﻧ<"code class="w3-codespan> ﯽﮔﮋﯾﻭ ،ﺪﺷﺎﺑ ﯽﻟ

HTML ﻡﺮﻓ ﻪﻧﻮﻤﻧ

<form action="/action_page.php" method="post">
  <input type="text" name="fname" required>
	<input type="submit" value="Submit">
</form>

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Validation</h2>

<form action="/action_page.php" method="post">
  <input type="text" name="fname" required>
  <input type="submit" value="Submit">
</form>

<p>If you click submit, without filling out the text field,
your browser will display an error message.</p>

</body>
</html>

.ﺪﻨﮐ ﯽﻤﻧ ﺭﺎﮐ ﻥﺁ ﺯﺍ ﻞﺒﻗ ﺎﯾ 9 ﺭﺭﻮﻠﭙﺴﮐﺍ ﺖﻧﺮﺘﻨﯾﺍ ﺭﺩ ﺭﺎﮐﺩﻮﺧ HTML ﻡﺮﻓ ﯽﺠﻨﺳ ﺭﺎﺒﺘﻋﺍ


ﺎﻫ ﻩﺩﺍﺩ ﯽﺠﻨﺳ ﺭﺎﺒﺘﻋﺍ

،ﺮﺑﺭﺎﮐ ﯼﺩﻭﺭﻭ ﻥﺩﻮﺑ ﮎﺎﭘ ﺯﺍ ﻥﺎﻨﯿﻤﻃﺍ ﯼﺍﺮﺑ ﺖﺳﺍ ﯼﺪﻨﯾﺁﺮﻓ ﻩﺩﺍﺩ ﯽﺠﻨﺳ ﺭﺎﺒﺘﻋﺍ

:ﺯﺍ ﺪﻨﺗﺭﺎﺒﻋ ﯽﻟﻮﻤﻌﻣ ﯽﺠﻨﺳﺭﺎﺒﺘﻋﺍ ﯼﺎﻫﺭﺎﮐ

  • ؟ﺖﺳﺍ ﻩﺩﺮﮐ ﺮﭘ ﺍﺭ ﻡﺯﻻ ﯼﺎﻫﺪﻠﯿﻓ ﻡﺎﻤﺗ ﺮﺑﺭﺎﮐ ﺎﯾﺁ

  • ؟ﺖﺳﺍ ﻩﺩﺮﮐ ﺩﺭﺍﻭ ﺍﺭ ﯼﺮﺒﺘﻌﻣ ﺦﯾﺭﺎﺗ ﺮﺑﺭﺎﮐ ﺎﯾﺁ

  • ؟ﺖﺳﺍ ﻩﺩﺮﮐ ﺩﺭﺍﻭ ﯼﺩﺪﻋ ﺪﻠﯿﻓ ﺭﺩ ﺍﺭ ﯽﻨﺘﻣ ﺮﺑﺭﺎﮐ ﺎﯾﺁ

.ﺖﺳﺍ ﺮﺑﺭﺎﮐ ﺢﯿﺤﺻ ﯼﺩﻭﺭﻭ ﺯﺍ ﻥﺎﻨﯿﻤﻃﺍ ﺎﻫ ﻩﺩﺍﺩ ﯽﺠﻨﺳﺭﺎﺒﺘﻋﺍ ﺯﺍ ﻑﺪﻫ ،ﺐﻠﻏﺍ

ﺖﻓﺭ ﺭﺎﮐ ﻪﺑ ﺎﻬﻧﺁ ﺯﺍ ﯼﺭﺎﯿﺴﺑ ﺭﺩ ﻭ ﺩﺮﮐ ﻒﯾﺮﻌﺗ ﯽﻔﻠﺘﺨﻣ ﯼﺎﻫ ﺵﻭﺭ ﺎﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﯽﺠﻨﺳ ﺭﺎﺒﺘﻋﺍ

ﺭﻭﺮﺳ ﺖﻤﺳ ﺭﺎﺒﺘﻋﺍ ﺪﯿﯾﺄﺗ ﺩﻮﺷ ﯽﻣ ﻡﺎﺠﻧﺍ ﺭﻭﺮﺳ ﻪﺑ ﯼﺩﻭﺭﻭ ﻝﺎﺳﺭﺍ ﺯﺍ ﺲﭘ ،ﺭﻭﺮﺳ ﺏ

.ﺩﻮﺷﯽﻣ ﻡﺎﺠﻧﺍ ﺏﻭ ﺮﮔﺭﻭﺮﻣ ﻂﺳﻮﺗ ﻩﺪﻧﺮﯿﮔ ﺲﯾﻭﺮﺳ ﺖﻤﺳ ﺭﺎﺒﺘﻋﺍ ﺪﯿﯾﺄﺗ ،ﺏﻭ ﺭ


HTML ﺖﯾﺩﻭﺪﺤﻣ ﯽﺠﻨﺳﺭﺎﺒﺘﻋﺍ

HTML5 ﺪﯾﺪﺟ ﯽﺠﻨﺳ ﺭﺎﺒﺘﻋﺍ ﻡﻮﻬﻔﻣ ﮏﯾ HTML ﻡﺎﻧ ﻪﺑ ﺩﺮﮐ ﯽﻓﺮﻌﻣ ﺍﺭ ﺖﯾﺩﻭﺪﺤﻣ

:ﺖﺳﺍ ﺮﯾﺯ ﺩﺭﺍﻮﻣ ﺱﺎﺳﺍ ﺮﺑ HTML ﺖﯾﺩﻭﺪﺤﻣ ﯽﺠﻨﺳ ﺭﺎﺒﺘﻋﺍ

  • ﯼﺩﻭﺭﻭ ﯼﺎﻫﯽﮔﮋﯾﻭHTML ﺖﯾﺩﻭﺪﺤﻣ ﯽﺠﻨﺳﺭﺎﺒﺘﻋﺍ

  • ﻪﺒﺷ ﯼﺎﻫﺮﮕﺑﺎﺨﺘﻧﺍ ﺖﯾﺩﻭﺪﺤﻣ ﯽﺠﻨﺳﺭﺎﺒﺘﻋﺍ

  • ﯼﺎﻫﺵﻭﺭ ﻭ ﺎﻫﯽﮔﮋﯾﻭ ﺖﯾﺩﻭﺪﺤﻣ ﯽﺠﻨﺳﺭﺎﺒﺘﻋﺍ


HTML ﯼﺩﻭﺭﻭ ﯼﺎﻫ ﯽﮔﮋﯾﻭ ﺖﯾﺩﻭﺪﺤﻣ ﯽﺠﻨﺳﺭﺎﺒﺘﻋﺍ

disabled

ﺩﻮﺷ ﻝﺎﻌﻓﺮﯿﻏ ﺪﯾﺎﺑ ﯼﺩﻭﺭﻭ ﺮﺼﻨﻋ ﻪﮐ ﺪﻨﮐ ﯽﻣ ﺺﺨﺸﻣ

max

ﺪﻨﮐ ﯽﻣ ﺺﺨﺸﻣ ﺍﺭ ﯼﺩﻭﺭﻭ ﺮﺼﻨﻋ ﮏﯾ ﺭﺍﺪﻘﻣ ﺮﺜﮐﺍﺪﺣ

min

ﺪﻨﮐ ﯽﻣ ﺺﺨﺸﻣ ﺍﺭ ﯼﺩﻭﺭﻭ ﺮﺼﻨﻋ ﮏﯾ ﺭﺍﺪﻘﻣ ﻞﻗﺍﺪﺣ

pattern

ﺪﻨﮐ ﯽﻣ ﺺﺨﺸﻣ ﺍﺭ ﯼﺩﻭﺭﻭ ﺮﺼﻨﻋ ﮏﯾ ﺭﺍﺪﻘﻣ ﯼﻮﮕﻟﺍ

required

ﺩﺭﺍﺩ ﺯﺎﯿﻧ ﺮﺼﻨﻋ ﮏﯾ ﻪﺑ ﯼﺩﻭﺭﻭ ﺪﻠﯿﻓ ﻪﮐ ﺪﻨﮐ ﯽﻣ ﺺﺨﺸﻣ

type 

ﺪﻨﮐ ﯽﻣ ﺺﺨﺸﻣ ﺍﺭ ﯼﺩﻭﺭﻭ ﺮﺼﻨﻋ ﻉﻮﻧ

ﺪﯾﻭﺮﺑ HTML ﻪﺑ ،ﻞﻣﺎﮐ ﺖﺴﯿﻟ ﯼﺍﺮﺑ


ﺖﯾﺩﻭﺪﺤﻣ ﯽﺠﻨﺳﺭﺎﺒﺘﻋﺍ CSS ﻪﺒﺷ ﯼﺎﻫﺮﮕﺑﺎﺨﺘﻧﺍ

:disabled

ﺪﻨﮐ ﯽﻣ ﺏﺎﺨﺘﻧﺍ ﻩﺪﺷ ﺺﺨﺸﻣ "ﻝﺎﻌﻓﺮﯿﻏ" ﯽﮔﮋﯾﻭ ﺎﺑ ﺍﺭ ﯼﺩﻭﺭﻭ ﺮﺻﺎﻨﻋ

:invalid

ﺪﻨﮐ ﯽﻣ ﺏﺎﺨﺘﻧﺍ ﺍﺭ ﺮﺒﺘﻌﻣﺎﻧ ﺮﯾﺩﺎﻘﻣ ﺎﺑ ﯼﺩﻭﺭﻭ ﺮﺻﺎﻨﻋ

:optional

ﺪﻨﮐ ﯽﻣ ﺏﺎﺨﺘﻧﺍ "ﯽﻣﺍﺰﻟﺍ" ﻪﺼﺨﺸﻣ ﻥﻭﺪﺑ ﺍﺭ ﯼﺩﻭﺭﻭ ﺮﺻﺎﻨﻋ

:required

ﺪﻨﮐ ﯽﻣ ﺏﺎﺨﺘﻧﺍ ﻩﺪﺷ ﺺﺨﺸﻣ "ﻡﺯﻻ" ﯽﮔﮋﯾﻭ ﺎﺑ ﺍﺭ ﯼﺩﻭﺭﻭ ﺮﺻﺎﻨﻋ

:valid

ﺪﻨﮐ ﯽﻣ ﺏﺎﺨﺘﻧﺍ ﺮﺒﺘﻌﻣ ﺮﯾﺩﺎﻘﻣ ﺎﺑ ﺍﺭ ﯼﺩﻭﺭﻭ ﺮﺻﺎﻨﻋ

ﺪﯾﻭﺮﺑ CSS ﻪﺑ ،ﻞﻣﺎﮐ ﺖﺴﯿﻟ ﯼﺍﺮﺑ

تمامی حقوق محفوظ است. © BasicIT.org • 2023-2024