ุฒูŠ ู…ุง ุนุฑูู†ุง ููŠ ู…ู‚ุงู„ Forms HTMLุŒ ุงู„ู€ <form> ุจุชุญุชูˆูŠ ุนู„ู‰ ุนู†ุงุตุฑ ุฅุฏุฎุงู„ ุนุดุงู† ู†ุฌู…ุน ุจูŠุงู†ุงุช ุงู„ูŠูˆุฒุฑ. ุงู„ุนู†ุตุฑ ุงู„ุฃูƒุซุฑ ุงุณุชุฎุฏุงู…ู‹ุง ุฌูˆู‡ ุงู„ููˆุฑู… ู‡ูˆ ุงู„ู€ <input>.

ุนู†ุตุฑ ุงู„ู€ <input>

ุฏู‡ ุฃู‡ู… ูˆุฃูƒุชุฑ ุนู†ุตุฑ ุจู†ุณุชุฎุฏู…ู‡ ููŠ ุงู„ููˆุฑู…. ุดูƒู„ ูˆูˆุธูŠูุฉ ุงู„ู€ <input> ุจูŠุชุบูŠุฑูˆุง ุจุดูƒู„ ูƒุจูŠุฑ ุฌุฏู‹ุง ุญุณุจ ู‚ูŠู…ุฉ ุงู„ู€ type attribute ุงู„ู„ูŠ ุจู†ุญุฏุฏู‡.

ุงู„ู€ cheat sheet ุฏูŠ ู‡ุชูƒูˆู† ู…ุฑุฌุน ู„ูŠูƒ ุนุดุงู† ุชุฎุชุงุฑ ุงู„ู€ type ุงู„ู…ู†ุงุณุจ ู„ูƒู„ ุญุงู„ุฉ. ุฃุบู„ุจ ุงู„ู€ inputs ุฏูŠ ูŠูุถู„ ุชุณุชุฎุฏู… ู…ุนุงู‡ุง <label> ุนุดุงู† ุงู„ู€ accessibility.

ุฃู†ูˆุงุน ุงู„ู€ type ู„ู„ู€ <input>

text

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนู…ู„ ุญู‚ู„ ู†ุตูŠ ุนุงุฏูŠ ู…ู† ุณุทุฑ ูˆุงุญุฏ (single-line text field) ุงู„ูŠูˆุฒุฑ ูŠู‚ุฏุฑ ูŠูƒุชุจ ููŠู‡.
  • ุฏู‡ ุงู„ู€ default value ู„ูˆ ู…ุญุฏุฏุชุด type.
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"> <!-- Standard text input -->


#### `password`
  • ุงู„ูˆุธูŠูุฉ: ุฒูŠ ุงู„ู€ textุŒ ุจุณ ุงู„ู‚ูŠู…ุฉ ุงู„ู„ูŠ ุจุชุชูƒุชุจ ุจุชูƒูˆู† ู…ุฎููŠุฉ (obscured)ุŒ ุนุดุงู† ูƒุฏู‡ ู…ู†ุงุณุจ ู„ู„ู…ุนู„ูˆู…ุงุช ุงู„ุญุณุงุณุฉ ุฒูŠ ุงู„ุจุงุณูˆุฑุฏุงุช.
  • ุงู„ูƒู„ุงู… ุจูŠุธู‡ุฑ ุนู„ู‰ ุดูƒู„ ู†ู‚ุท ุฃูˆ ู†ุฌูˆู….
<label for="pwd">Password:</label>
<input type="password" id="pwd" name="pwd"> <!-- Input is masked -->

button

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนุฑุถ ุฒุฑุงุฑ ุนุงุฏูŠ ุชู‚ุฏุฑ ุชุฏูˆุณ ุนู„ูŠู‡ (clickable button).
  • ุบุงู„ุจู‹ุง ุจู†ุณุชุฎุฏู…ู‡ ุนุดุงู† ู†ู†ูุฐ script (ูƒูˆุฏ JavaScript) ู„ู…ุง ู†ุฏูˆุณ ุนู„ูŠู‡ ุจุงุณุชุฎุฏุงู… ุงู„ู€ onclick attribute.
<!-- Executes the msg() JavaScript function on click -->
<input type="button" value="Click me" onclick="msg()" />
  • ู…ู„ุญูˆุธุฉ: ู…ู…ูƒู† ุจุฑุถู‡ ุชุนู…ู„ ุฒุฑุงูŠุฑ ุจุงุณุชุฎุฏุงู… ุชุงุฌ ุงู„ู€ Buttons HTML. ุงู„ู…ูŠุฒุฉ ููŠ <button> ุฅู†ูƒ ุชู‚ุฏุฑ ุชุญุท ุฌูˆุงู‡ ู…ุญุชูˆู‰ ุฒูŠ ู†ุตูˆุต ูˆุตูˆุฑุŒ ู…ุด ู…ุฌุฑุฏ ู‚ูŠู…ุฉ ููŠ ุงู„ู€ value.
    <button onclick="alert('Are you sure you want to continue?')">
        <!-- Can contain images and text -->
        <img src="https://yourserver.com/button_img.jpg"
            alt="Submit the form" height="64" width="64">
            Confirm
    </button>

checkbox

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนู…ู„ checkbox (ู…ุฑุจุน ุงุฎุชูŠุงุฑ) ุจูŠุณู…ุญ ู„ู„ูŠูˆุฒุฑ ูŠุฎุชุงุฑ ู‚ูŠู…ุฉ ูˆุงุญุฏุฉ ุฃูˆ ูŠู„ุบูŠ ุงุฎุชูŠุงุฑู‡ุง.
  • ุจู†ุณุชุฎุฏู…ู‡ ู„ู…ุง ูŠูƒูˆู† ุนู†ุฏ ุงู„ูŠูˆุฒุฑ ู…ุฌู…ูˆุนุฉ ุฎูŠุงุฑุงุช ู…ุญุฏูˆุฏุฉ ูˆุนุงูŠุฒูŠู†ู‡ ูŠู‚ุฏุฑ ูŠุฎุชุงุฑ ุตูุฑ ุฃูˆ ุฃูƒุชุฑ ู…ู† ุงู„ุฎูŠุงุฑุงุช ุฏูŠ.
<!-- User can select zero or more options -->
<input type="checkbox" id="dog" name="likes" value="Dog"> <!-- Added name attribute -->
<label for="dog">I like dogs</label>
<input type="checkbox" id="cat" name="likes" value="Cat"> <!-- Added name attribute -->
<label for="cat">I like cats</label>
  • ุนุดุงู† ุชุฎู„ูŠ ูˆุงุญุฏ ู…ู†ู‡ู… ู…ุชุนู„ู… ุนู„ูŠู‡ ุจุดูƒู„ ุงูุชุฑุงุถูŠุŒ ุงุณุชุฎุฏู… ุงู„ู€ checked attribute:
    <input type="checkbox" id="bike" name="vehicle" value="bike" checked /> <!-- Pre-selected checkbox -->

radio

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนุฑุถ radio button (ุฒุฑ ุงุฎุชูŠุงุฑ ุฏุงุฆุฑูŠ).
  • ุจูŠุณู…ุญ ู„ู„ูŠูˆุฒุฑ ูŠุฎุชุงุฑ ู‚ูŠู…ุฉ ูˆุงุญุฏุฉ ุจุณ ู…ู† ุจูŠู† ู…ุฌู…ูˆุนุฉ ุฎูŠุงุฑุงุช.
  • ุจูŠุชู‚ุฏู…ูˆุง ุนุงุฏุฉ ููŠ ู…ุฌู…ูˆุนุงุช (radio groups): ู…ุฌู…ูˆุนุฉ radio buttons ู„ูŠู‡ู… ู†ูุณ ุงู„ู€ name attribute. ู„ู…ุง ูŠูƒูˆู† ู„ูŠู‡ู… ู†ูุณ ุงู„ู€ nameุŒ ุงู„ูŠูˆุฒุฑ ู…ูŠู†ูุนุด ูŠุฎุชุงุฑ ุบูŠุฑ ูˆุงุญุฏ ุจุณ ู…ู†ู‡ู… ููŠ ู†ูุณ ุงู„ูˆู‚ุช.
<!-- User can select only one option with the same name -->
<input type="radio" id="light" name="theme" value="Light"> <!-- Value is important -->
<label for="light">Light</label>
<input type="radio" id="dark" name="theme" value="Dark">
<label for="dark">Dark</label>
  • ุฒูŠ ุงู„ู€ checkboxุŒ ู…ู…ูƒู† ุชุณุชุฎุฏู… checked ุนุดุงู† ุชุฎู„ูŠ ุงุฎุชูŠุงุฑ ุงูุชุฑุงุถูŠ.
  • ุงู„ู€ value ู‡ู†ุง ู…ู‡ู… ุฌุฏู‹ุง ุนุดุงู† ู‡ูˆ ุฏู‡ ุงู„ู„ูŠ ุจูŠุชุจุนุช ู„ู„ุณูŠุฑูุฑ ู„ู…ุง ุงู„ูŠูˆุฒุฑ ูŠุฎุชุงุฑ ุงู„ู€ radio button ุฏู‡.

submit

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนุฑุถ ุฒุฑุงุฑ submit. ู„ู…ุง ุงู„ูŠูˆุฒุฑ ุจูŠุฏูˆุณ ุนู„ูŠู‡ุŒ ุจูŠุจุนุช ูƒู„ ุงู„ู‚ูŠู… ุงู„ู„ูŠ ููŠ ุงู„ููˆุฑู… ู„ู„ู€ form-handler (ุงู„ู„ูŠ ู…ุชุญุฏุฏ ููŠ ุงู„ู€ action attribute ุจุชุงุน ุงู„ููˆุฑู…).
  • ุงุชูƒู„ู…ู†ุง ุนู†ู‡ุง ุจุงู„ุชูุตูŠู„ ููŠ submit HTML
<form action="myserver.com" method="POST">
  <!-- Other form elements go here -->
  <input type="submit" value="Submit" /> <!-- Submits the form data -->
</form>
  • ู„ูˆ ู…ุญุทุชุด value ู„ู„ุฒุฑุงุฑุŒ ู‡ูŠุงุฎุฏ ู‚ูŠู…ุฉ ุงูุชุฑุงุถูŠุฉ (ุฒูŠ โ€œSubmitโ€).

reset

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนุฑุถ ุฒุฑุงุฑ ุจูŠุฑุฌุน ูƒู„ ู‚ูŠู… ุงู„ููˆุฑู… ู„ู‚ูŠู…ู‡ุง ุงู„ุงูุชุฑุงุถูŠุฉ (default values).
<input type="reset" value="Reset"> <!-- Resets form fields to default -->

date

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนุฑุถ ุฃุฏุงุฉ ุชุญูƒู… (control) ุนุดุงู† ุงู„ูŠูˆุฒุฑ ูŠุฏุฎู„ ุชุงุฑูŠุฎ (ุณู†ุฉุŒ ุดู‡ุฑุŒ ูŠูˆู…) ู…ู† ุบูŠุฑ ูˆู‚ุช. ุดูƒู„ ุงู„ุฃุฏุงุฉ ุจูŠุฎุชู„ู ุญุณุจ ุงู„ู…ุชุตูุญ.
<label for="dob">Date of birth:</label>
<input type="date" id="dob" name="date_of_birth"> <!-- Date picker -->
  • ู…ู…ูƒู† ุชุณุชุฎุฏู… min ูˆ max ุนุดุงู† ุชุญุฏุฏ ู…ุฏู‰ ุชูˆุงุฑูŠุฎ ู…ุณู…ูˆุญ ุจูŠู‡.
<form>  
ย ย <labelย for="datemax">Enter a date before 1980-01-01:</label>  
ย ย <inputย type="date"ย id="datemax"ย name="datemax"ย max="1979-12-31"><br><br>  
ย ย <labelย for="datemin">Enter a date after 2000-01-01:</label>  
ย ย <inputย type="date"ย id="datemin"ย name="datemin"ย min="2000-01-02">  
</form>

datetime-local

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนุฑุถ ุฃุฏุงุฉ ุชุญูƒู… ุนุดุงู† ุงู„ูŠูˆุฒุฑ ูŠุฏุฎู„ ุชุงุฑูŠุฎ ูˆูˆู‚ุช ู…ุน ุจุนุถ (ุณู†ุฉุŒ ุดู‡ุฑุŒ ูŠูˆู…ุŒ ุณุงุนุฉุŒ ุฏู‚ูŠู‚ุฉ).
<label for="birthdaytime">Birthday (date and time):</label>
<input type="datetime-local" id="birthdaytime" name="birthdaytime"> <!-- Date and time picker -->

time

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนุฑุถ ุฃุฏุงุฉ ุชุญูƒู… ุนุดุงู† ุงู„ูŠูˆุฒุฑ ูŠุฏุฎู„ ูˆู‚ุช (ุณุงุนุฉ ูˆุฏู‚ูŠู‚ุฉ) ู…ู† ุบูŠุฑ time zone.
<label for="appt">Select a time:</label>
<input type="time" id="appt" name="appt"> <!-- Time picker -->

month

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนุฑุถ ุฃุฏุงุฉ ุชุญูƒู… ุนุดุงู† ุงู„ูŠูˆุฒุฑ ูŠุฏุฎู„ ุดู‡ุฑ ูˆุณู†ุฉุŒ ู…ู† ุบูŠุฑ time zone.
  • ุฎุฏ ุจุงู„ูƒ: ุฏู‡ ู†ูˆุน ุฌุฏูŠุฏ ู†ุณุจูŠู‹ุง ูˆู…ู…ูƒู† ู…ุด ูƒู„ ุงู„ู…ุชุตูุญุงุช ุชุฏุนู…ู‡. (ุงุชุฃูƒุฏ ู…ู† Can I use)
<label for="bdaymonth">Birthday (month and year):</label>
<input type="month" id="bdaymonth" name="bdaymonth" min="1930-01" value="2000-01"> <!-- Month and year picker -->

week

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนุฑุถ ุฃุฏุงุฉ ุชุญูƒู… ุนุดุงู† ุงู„ูŠูˆุฒุฑ ูŠุฏุฎู„ ุชุงุฑูŠุฎ ุนุจุงุฑุฉ ุนู† ุฑู‚ู… ุงู„ุฃุณุจูˆุน ููŠ ุงู„ุณู†ุฉ ูˆุงู„ุณู†ุฉ ู†ูุณู‡ุงุŒ ู…ู† ุบูŠุฑ time zone.
  • ุฎุฏ ุจุงู„ูƒ: ุฏู‡ ุจุฑุถู‡ ู†ูˆุน ุฌุฏูŠุฏ ูˆู…ู…ูƒู† ู…ุด ูƒู„ ุงู„ู…ุชุตูุญุงุช ุชุฏุนู…ู‡.
<label for="week">Select a week:</label>
<input type="week" id="week" name="week"> <!-- Week and year picker -->

email

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนู…ู„ ุญู‚ู„ ู…ุฎุตุต ู„ุนู†ูˆุงู† ุงู„ุจุฑูŠุฏ ุงู„ุฅู„ูƒุชุฑูˆู†ูŠ (email address).
  • ุจูŠุจู‚ู‰ ุดุจู‡ ุงู„ู€ text ุงู„ุนุงุฏูŠุŒ ู„ูƒู† ุงู„ู…ุชุตูุญ ุจูŠุนู…ู„ู‡ validation (ุชุญู‚ู‚) ุชู„ู‚ุงุฆูŠ ุฅู† ุงู„ุตูŠุบุฉ ุจุชุงุนุชู‡ ุตุญ ู„ู…ุง ุชูŠุฌูŠ ุชุนู…ู„ submit ู„ู„ููˆุฑู….
  • ุจุนุถ ุงู„ู…ูˆุจุงูŠู„ุงุช ุจุชุบูŠุฑ ุดูƒู„ ุงู„ูƒูŠุจูˆุฑุฏ ุนุดุงู† ุชุณู‡ู„ ูƒุชุงุจุฉ ุงู„ุฅูŠู…ูŠู„ (ุฒูŠ ุฅุถุงูุฉ ุฒุฑุงุฑ .com).
<label for="email">Enter your email:</label>
<input type="email" id="email" name="email"> <!-- Validates email format on submit -->

tel

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนู…ู„ ุญู‚ู„ ู…ุฎุตุต ู„ุฑู‚ู… ุงู„ุชู„ูŠููˆู†.
  • ุงู„ู…ุชุตูุญุงุช ุงู„ู„ูŠ ู…ุด ุจุชุฏุนู…ู‡ ุจุชุชุนุงู…ู„ ู…ุนุงู‡ ูƒุฃู†ู‡ text.
  • ู…ู…ูƒู† ุชุณุชุฎุฏู… ุงู„ู€ pattern attribute ุนุดุงู† ุชุนู…ู„ validation ุนู„ู‰ ุดูƒู„ ุงู„ุฑู‚ู… ุงู„ู…ุทู„ูˆุจ.
<label for="phone">Enter your phone number:</label>
<!-- The pattern attribute defines a regex for input validation -->
<input type="tel" id="phone" name="phone" pattern="[+]{1}[0-9]{11,14}"> <!-- Example pattern for international numbers -->

url

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนู…ู„ ุญู‚ู„ ู…ุฎุตุต ู„ู„ู€ URL (ุนู†ูˆุงู† ู…ูˆู‚ุน ูˆูŠุจ).
  • ุฒูŠ ุงู„ู€ emailุŒ ุงู„ู…ุชุตูุญ ุจูŠุนู…ู„ู‡ validation ุชู„ู‚ุงุฆูŠ ู„ู„ุตูŠุบุฉ ุจุชุงุนุชู‡ ุนู†ุฏ ุงู„ู€ submit.
  • ุจุนุถ ุงู„ู…ูˆุจุงูŠู„ุงุช ุจุชุบูŠุฑ ุงู„ูƒูŠุจูˆุฑุฏ ุนุดุงู† ุชุณู‡ู„ ูƒุชุงุจุฉ ุงู„ู€ URL.
<label for="homepage">Add your homepage:</label>
<input type="url" id="homepage" name="homepage"> <!-- Validates URL format on submit -->

file

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนุฑุถ ุฃุฏุงุฉ ุชุญูƒู… ุจุชุณู…ุญ ู„ู„ูŠูˆุฒุฑ ูŠุฎุชุงุฑ ู…ู„ู ู…ู† ุฌู‡ุงุฒู‡ ุนุดุงู† ูŠุนู…ู„ู‡ upload. ุจูŠุธู‡ุฑ ุฒุฑุงุฑ ุฒูŠ โ€œBrowseโ€ ุฃูˆ โ€œChoose Fileโ€.
<label for="myfile">Select a file:</label>
<input type="file" id="myfile" name="myfile"> <!-- File selection control -->
  • ุงู„ู€ accept attribute: ู…ู…ูƒู† ุชุณุชุฎุฏู…ู‡ ุนุดุงู† ุชุญุฏุฏ ุฃู†ูˆุงุน ุงู„ู…ู„ูุงุช ุงู„ู…ุณู…ูˆุญ ุจูŠู‡ุง (ุงู„ู…ุชุตูุญ ู‡ูŠุญุงูˆู„ ูŠูู„ุชุฑ ุงู„ู…ู„ูุงุช ู„ู„ูŠูˆุฒุฑุŒ ู„ูƒู† ุฏู‡ ู…ุด ุจูŠู…ู†ุน ุงู„ูŠูˆุฒุฑ ูŠุฎุชุงุฑ ู†ูˆุน ุชุงู†ูŠ).
    <!-- Allow only PNG images -->
    <input type="file" accept="image/png" name="profilePicPng">
    <!-- Allow any image type -->
    <input type="file" accept="image/*" name="profilePicAny">
  • ุงู„ู€ multiple attribute: ู„ูˆ ุถูุชู‡ุŒ ู‡ูŠุณู…ุญ ู„ู„ูŠูˆุฒุฑ ูŠุฎุชุงุฑ ุฃูƒุชุฑ ู…ู† ู…ู„ู ููŠ ู†ูุณ ุงู„ูˆู‚ุช.
    <!-- Allow multiple image file selections -->
    <input type="file" accept="image/*" name="galleryPics" multiple/>

hidden

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนู…ู„ ุญู‚ู„ ุฅุฏุฎุงู„ ุจูŠูƒูˆู† ู…ุฎููŠ ูˆู…ุด ุธุงู‡ุฑ ู„ู„ูŠูˆุฒุฑ ููŠ ุงู„ุตูุญุฉ.
  • ูุงูŠุฏุชู‡ ุฅูŠู‡ุŸ ุจู†ุณุชุฎุฏู…ู‡ ุนุดุงู† ู†ุจุนุช ุจูŠุงู†ุงุช ู„ู„ุณูŠุฑูุฑ ุงู„ูŠูˆุฒุฑ ู…ุด ู…ุญุชุงุฌ ูŠุดูˆูู‡ุง ุฃูˆ ูŠุนุฏู„ู‡ุงุŒ ุฒูŠ ู…ุซู„ู‹ุง id ุจุชุงุน ุนู…ูŠู„ ุฃูˆ ุฃูŠ ุจูŠุงู†ุงุช ุชุชุจุน ุชุงู†ูŠุฉ.
<form>
    <label for="fname"> First name:</label>
    <input type="text" id="fname" name="fname"> <br><br>
    <!-- This field is hidden but its value is submitted -->
    <input type="hidden" id="custID" name="custId" value="3487">
    <input type="submit" value="Submit">
</form>
  • ุชุญุฐูŠุฑ: ุฑุบู… ุฅู† ุงู„ุญู‚ู„ ุฏู‡ ู…ุด ุธุงู‡ุฑุŒ ุฃูŠ ุญุฏ ูŠู‚ุฏุฑ ูŠุดูˆู ู‚ูŠู…ุชู‡ ูˆูŠุนุฏู„ู‡ุง ุจุงุณุชุฎุฏุงู… ุฃุฏูˆุงุช ุงู„ู…ุทูˆุฑูŠู† (developer tools) ููŠ ุงู„ู…ุชุตูุญ ุฃูˆ ุนู† ุทุฑูŠู‚ โ€œView Sourceโ€. ุฃูˆุนู‰ ุชุณุชุฎุฏู…ู‡ ูƒูˆุณูŠู„ุฉ ุฃู…ุงู†!

image

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนุฑุถ ุตูˆุฑุฉ ุจุชุดุชุบู„ ูƒุฃู†ู‡ุง ุฒุฑุงุฑ submit ุฑุณูˆู…ูŠ (graphical submit button).
  • ู„ุงุฒู… ุชุณุชุฎุฏู… ุงู„ู€ src attribute ุนุดุงู† ุชุญุฏุฏ ู…ูƒุงู† ู…ู„ู ุงู„ุตูˆุฑุฉ.
<!-- Image acts as a submit button -->
<input type="image" src="submit_img.png" alt="Submit" width="48" height="48">

number

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนู…ู„ ุญู‚ู„ ู…ุฎุตุต ู„ุฅุฏุฎุงู„ ุงู„ุฃุฑู‚ุงู…. ุงู„ู…ุชุตูุญ ุบุงู„ุจู‹ุง ุจูŠุนุฑุถ ุฃุณู‡ู… ุตุบูŠุฑุฉ ุนุดุงู† ุชุฒูˆุฏ ุฃูˆ ุชู†ู‚ุต ุงู„ุฑู‚ู….
  • ู…ู…ูƒู† ุชุณุชุฎุฏู… attributes ุฒูŠ min, max, step ุนุดุงู† ุชุญุท ู‚ูŠูˆุฏ ุนู„ู‰ ุงู„ุฃุฑู‚ุงู… ุงู„ู…ุณู…ูˆุญุฉ.
<label for="quantity">Quantity (between 1 and 5):</label>
<input type="number" id="quantity" name="quantity" min="1" max="5"> <!-- Numeric input with range -->

range

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนุฑุถ widget (ุฒูŠ slider ุฃูˆ ู…ุคุดุฑ) ุนุดุงู† ุงู„ูŠูˆุฒุฑ ูŠุฎุชุงุฑ ุฑู‚ู… ููŠ ู…ุฏู‰ ู…ุนูŠู†. ุงู„ู‚ูŠู…ุฉ ุงู„ุฏู‚ูŠู‚ุฉ ู†ูุณู‡ุง ู…ุด ุจุชูƒูˆู† ู…ู‡ู…ุฉ ุฃูˆูŠ ุฒูŠ ููŠ ุญุงู„ุฉ ุงู„ู€ number.
  • ุจู†ุณุชุฎุฏู… min ูˆ max ุนุดุงู† ู†ุญุฏุฏ ุงู„ู…ุฏู‰ ุงู„ู…ุณู…ูˆุญ. ุงู„ู‚ูŠู…ุฉ ุงู„ุงูุชุฑุงุถูŠุฉ ู„ู„ู…ุฏู‰ ู‡ูŠ ู…ู† 0 ู„ู€ 100.
<label for="volume">Volume:</label>
<!-- Slider control for selecting a value in a range -->
<input type="range" id="volume" name="volume" min="0" max="10">
  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนู…ู„ ุญู‚ู„ ู†ุตูŠ ู…ุฎุตุต ู„ูƒุชุงุจุฉ ุงุณุชุนู„ุงู…ุงุช ุงู„ุจุญุซ (search query).
  • ู…ู† ู†ุงุญูŠุฉ ุงู„ูˆุธูŠูุฉ ู‡ูˆ ุฒูŠ ุงู„ู€ text ุจุงู„ุธุจุทุŒ ู„ูƒู† ู…ู…ูƒู† ุงู„ู…ุชุตูุญ ูŠุนุฑุถู‡ ุจุดูƒู„ ู…ุฎุชู„ู ุดูˆูŠุฉ (ุฒูŠ ุฅู†ู‡ ูŠุญุท ุนู„ุงู…ุฉ x ุตุบูŠุฑุฉ ู„ู…ุณุญ ุงู„ู†ุต).
<label for="gsearch">Search in Google:</label>
<input type="search" id="gsearch" name="gsearch"> <!-- Text input styled for search -->

color

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนู…ู„ ุญู‚ู„ ุจูŠุณู…ุญ ู„ู„ูŠูˆุฒุฑ ูŠุฎุชุงุฑ ู„ูˆู† (ุบุงู„ุจู‹ุง ุจูŠูุชุญ color picker).
  • ู…ุด ู…ุฏุนูˆู… ููŠ ุงู„ู…ุชุตูุญุงุช ุงู„ู‚ุฏูŠู…ุฉ (ุฒูŠ IE). ุงุชุฃูƒุฏ ู…ู† Can I use.
<label for="favcolor">Select your favorite color:</label>
<input type="color" id="favcolor" name="favcolor"> <!-- Color picker control -->

ุฃู‡ู… ุงู„ู€ Attributes ู„ุนู†ุงุตุฑ ุงู„ู€ <input> (ูˆุบูŠุฑู‡ุง)

ุงุชูƒู„ู…ู†ุง ุนู† ุงู„ู€ Attributes HTML ู‚ุจู„ ูƒุฏุง

ุบูŠุฑ ุงู„ู€ typeุŒ ููŠู‡ attributes ุชุงู†ูŠุฉ ู…ู‡ู…ุฉ ุฌุฏู‹ุง ุจู†ุณุชุฎุฏู…ู‡ุง ู…ุน ุงู„ู€ <input> ูˆุนู†ุงุตุฑ ุชุงู†ูŠุฉ ููŠ ุงู„ููˆุฑู…:

name

  • ุงู„ุฃู‡ู…ูŠุฉ: ุถุฑูˆุฑูŠ ุฌุฏู‹ุง ู„ุฃูŠ Input type ุนุงูŠุฒ ุชุจุนุช ู‚ูŠู…ุชู‡ ู„ู„ุณูŠุฑูุฑ.
  • ูˆุธูŠูุชู‡: ุจูŠุญุฏุฏ ุงุณู… ุงู„ุญู‚ู„ ุฏู‡. ู„ู…ุง ุงู„ููˆุฑู… ุจุชุชุจุนุชุŒ ุงู„ุจูŠุงู†ุงุช ุจุชูˆุตู„ ู„ู„ุณูŠุฑูุฑ ุนู„ู‰ ุดูƒู„ name=value.
  • ู„ูˆ ุญุฐูุช ุงู„ู€ name attributeุŒ ู‚ูŠู…ุฉ ุงู„ุญู‚ู„ ุฏู‡ ู…ุด ู‡ุชุชุจุนุช ุฃุตู„ู‹ุง.
  • ู„ุบุงุช ุงู„ู€ Backend ุจุชุณุชุฎุฏู… ุงู„ู€ name ุฏู‡ ุนุดุงู† ุชุนุฑู ูƒู„ ู‚ูŠู…ุฉ ุฌุงูŠุฉ ุจุชุงุนุฉ ุฃู†ู‡ูŠ ุญู‚ู„ ุจุงู„ุธุจุท.
<!-- Server-side will receive: firstname=Mahmoud -->
<input id="fname" type="text" name="firstname" />
  • ู…ู„ุญูˆุธุฉ: ู…ูŠู†ูุนุด ุชูƒุฑุฑ ู†ูุณ ุงู„ู€ name ู„ุนู†ุงุตุฑ ู…ุฎุชู„ูุฉ ููŠ ู†ูุณ ุงู„ููˆุฑู… ุฅู„ุง ููŠ ุญุงู„ุฉ ุงู„ู€ radio buttons (ุนุดุงู† ุชุนู…ู„ ู…ุฌู…ูˆุนุฉ) ุฃูˆ ุงู„ู€ checkboxes (ู„ูˆ ุนุงูŠุฒ ุชุฌู…ุน ุงู„ู‚ูŠู… ููŠ list ุฃูˆ array ููŠ ุงู„ู€ backend). ู„ูˆ ูƒุฑุฑุช ุงู„ู€ name ู„ุนู†ุงุตุฑ text ู…ุซู„ู‹ุงุŒ ู…ู…ูƒู† ูŠุนู…ู„ override (ุขุฎุฑ ู‚ูŠู…ุฉ ู‡ูŠ ุงู„ู„ูŠ ู‡ุชุชุจุนุช) ูˆุฏู‡ ู‡ูŠุณุจุจ ู…ุดุงูƒู„.

value

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุญุฏุฏ ุงู„ู‚ูŠู…ุฉ ุงู„ู…ุจุฏุฆูŠุฉ (initial value) ู„ู„ุญู‚ู„.
  • ู…ู‡ู… ุฌุฏู‹ุง ู…ุน ุงู„ู€ checkbox ูˆุงู„ู€ radio ุนุดุงู† ู‡ูˆ ุฏู‡ ุงู„ู„ูŠ ุจูŠุญุฏุฏ ุงู„ู‚ูŠู…ุฉ ุงู„ู„ูŠ ู‡ุชุชุจุนุช ู„ู„ุณูŠุฑูุฑ ู„ู…ุง ุงู„ูŠูˆุฒุฑ ูŠุฎุชุงุฑ ุงู„ุนู†ุตุฑ ุฏู‡.
  • ู…ุน ุงู„ู€ text, password, ูˆุบูŠุฑู‡ุงุŒ ุจุชุจู‚ู‰ ุงู„ู‚ูŠู…ุฉ ุงู„ู„ูŠ ุธุงู‡ุฑุฉ ููŠ ุงู„ุญู‚ู„ ุฃูˆู„ ู…ุง ุงู„ุตูุญุฉ ุชุญู…ู„.
<input type="text" id="fname" name="fname" value="John"> <!-- Field will initially contain "John" -->
<input type="radio" id="html" name="fav_language" value="HTML"> <!-- If selected, submits fav_language=HTML -->

readonly

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุฎู„ูŠ ุงู„ุญู‚ู„ ู„ู„ู‚ุฑุงุกุฉ ูู‚ุท (read-only).
  • ุงู„ูŠูˆุฒุฑ ู…ูŠู‚ุฏุฑุด ูŠุนุฏู„ ุงู„ู‚ูŠู…ุฉุŒ ู„ูƒู† ูŠู‚ุฏุฑ ูŠูˆุตู„ู‡ ุจุงู„ู€ tabุŒ ูˆูŠุนู…ู„ highlight ู„ู„ู†ุตุŒ ูˆูŠู†ุณุฎู‡.
  • ู…ู‡ู…: ู‚ูŠู…ุฉ ุงู„ุญู‚ู„ ุงู„ู€ readonly ุจุชุชุจุนุช ู…ุน ุงู„ููˆุฑู… ู„ู…ุง ุชุนู…ู„ submit.
<input type="text" id="fname" name="fname" value="John" readonly> <!-- Value cannot be changed by user, but is submitted -->

disabled

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนุทู„ ุงู„ุญู‚ู„ (disabled).
  • ุงู„ุญู‚ู„ ุจูŠุจู‚ู‰ ุบูŠุฑ ู‚ุงุจู„ ู„ู„ุงุณุชุฎุฏุงู… ูˆู…ูŠู†ูุนุด ุชุฏูˆุณ ุนู„ูŠู‡ ุฃูˆ ุชุนุฏู„ู‡. ุดูƒู„ู‡ ูƒู…ุงู† ุจูŠุจู‚ู‰ ุจุงู‡ุช ุบุงู„ุจู‹ุง.
  • ู…ู‡ู…: ู‚ูŠู…ุฉ ุงู„ุญู‚ู„ ุงู„ู€ disabled ู…ุด ุจุชุชุจุนุช ู…ุน ุงู„ููˆุฑู… ู„ู…ุง ุชุนู…ู„ submit.
<input type="text" id="fname" name="fname" value="John" disabled> <!-- Field is unusable and value is NOT submitted -->

min ูˆ max

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุญุฏุฏูˆุง ุฃู‚ู„ ู‚ูŠู…ุฉ (minimum) ูˆุฃู‚ุตู‰ ู‚ูŠู…ุฉ (maximum) ู…ุณู…ูˆุญุฉ ู„ู„ุญู‚ู„.
  • ุจูŠุดุชุบู„ูˆุง ู…ุน ุฃู†ูˆุงุน ุงู„ู€ input ุฏูŠ: number, range, date, datetime-local, month, time, week.
  • ู…ู…ูƒู† ุชุณุชุฎุฏู…ู‡ู… ู…ุน ุจุนุถ ุนุดุงู† ุชุญุฏุฏ ู…ุฏู‰ ู…ุนูŠู† ู„ู„ู‚ูŠู… ุงู„ู…ุณู…ูˆุญุฉ.
<input type="number" id="quantity" name="quantity" min="1" max="5"> <!-- Allows numbers between 1 and 5 -->
<input type="date" id="datemax" name="datemax" max="1979-12-31"> <!-- Latest allowed date -->

maxlength ูˆ minlength

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุญุฏุฏูˆุง ุฃู‚ุตู‰ (maximum) ูˆุฃู‚ู„ (minimum) ุนุฏุฏ ุญุฑูˆู ู…ุณู…ูˆุญ ุจูŠู‡ ููŠ ุงู„ุญู‚ู„.
  • ุจู†ุณุชุฎุฏู…ู‡ู… ู…ุน ุฃู†ูˆุงุน ุงู„ุฅุฏุฎุงู„ ุงู„ู†ุตูŠุฉ ุฒูŠ text, password, search, tel, url, email.
<input type="text" name="username" minlength="5" maxlength="15"> <!-- Defines allowed text length -->

placeholder

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนุฑุถ ู†ุต ุชู„ู…ูŠุญูŠ (hint) ู…ุคู‚ุช ุฌูˆู‡ ุงู„ุญู‚ู„ ู‚ุจู„ ู…ุง ุงู„ูŠูˆุฒุฑ ูŠุจุฏุฃ ูŠูƒุชุจ.
  • ุงู„ุชู„ู…ูŠุญ ุฏู‡ ุจูŠูˆุตู ุงู„ู‚ูŠู…ุฉ ุงู„ู…ุชูˆู‚ุนุฉ (ุฒูŠ ู…ุซุงู„ ุฃูˆ ูˆุตู ู‚ุตูŠุฑ ู„ู„ุตูŠุบุฉ ุงู„ู…ุทู„ูˆุจุฉ). ุจูŠุฎุชููŠ ุฃูˆู„ ู…ุง ุงู„ูŠูˆุฒุฑ ูŠูƒุชุจ.
  • ุจูŠุดุชุบู„ ู…ุน ุฃู†ูˆุงุน ุงู„ู€ input ุฏูŠ: text, search, url, number, tel, email, password.
<input type="tel" id="phone" name="phone" placeholder="123-45-678"> <!-- Hint shown before user types -->

autofocus

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุฎู„ูŠ ุงู„ู€ focus (ู…ุคุดุฑ ุงู„ูƒุชุงุจุฉ) ูŠุฑูˆุญ ุนู„ู‰ ุงู„ุญู‚ู„ ุฏู‡ ุชู„ู‚ุงุฆูŠู‹ุง ุฃูˆู„ ู…ุง ุงู„ุตูุญุฉ ุชุญู…ู„.
  • ุงู„ู…ูุฑูˆุถ ุชุณุชุฎุฏู…ู‡ ู…ุฑุฉ ูˆุงุญุฏุฉ ุจุณ ููŠ ุงู„ุตูุญุฉ.
<input type="text" id="fname" name="fname" autofocus> <!-- Gets focus automatically on page load -->

required

  • ุงู„ูˆุธูŠูุฉ: ุจูŠูˆุถุญ ุฅู† ุงู„ุญู‚ู„ ุฏู‡ ู…ุทู„ูˆุจ (required)ุŒ ูˆุงู„ูŠูˆุฒุฑ ู„ุงุฒู… ูŠุฏุฎู„ ููŠู‡ ู‚ูŠู…ุฉ ูˆู…ูŠู†ูุนุด ูŠุณูŠุจู‡ ูุงุถูŠ.
  • ู„ูˆ ุงู„ูŠูˆุฒุฑ ุญุงูˆู„ ูŠุนู…ู„ submit ูˆุงู„ููˆุฑู… ููŠู‡ุง ุญู‚ู„ required ูุงุถูŠุŒ ุงู„ู…ุชุตูุญ ู‡ูŠู…ู†ุน ุงู„ู€ submission ูˆู‡ูŠุทู„ุน ุฑุณุงู„ุฉ ุชู†ุจูŠู‡.
<input type="email" name="email" required> <!-- This field must be filled out -->

checked

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุฎู„ูŠ ุงู„ู€ checkbox ุฃูˆ ุงู„ู€ radio button ู…ุชุนู„ู… ุนู„ูŠู‡ (checked) ุจุดูƒู„ ุงูุชุฑุงุถูŠ ุฃูˆู„ ู…ุง ุงู„ุตูุญุฉ ุชุญู…ู„.
<input type="radio" id="html" name="fav_language" value="HTML" checked> <!-- Default selected radio -->
<input type="checkbox" id="agree" name="agree" checked> <!-- Default checked checkbox -->

pattern

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุณู…ุญู„ูƒ ุชุญุฏุฏ regular expression (ุชุนุจูŠุฑ ู†ู…ุทูŠ) ุงู„ู‚ูŠู…ุฉ ุงู„ู„ูŠ ุงู„ูŠูˆุฒุฑ ุจูŠุฏุฎู„ู‡ุง ู„ุงุฒู… ุชุทุงุจู‚ู‡ ุนุดุงู† ุชุนุชุจุฑ ุตุญูŠุญุฉ.
  • ุฏู‡ ุจูŠูˆูุฑ ุทุฑูŠู‚ุฉ ู‚ูˆูŠุฉ ู„ู„ู€ client-side validation ู„ุฃุดูƒุงู„ ู…ุนู‚ุฏุฉ.
  • ุจูŠุดุชุบู„ ู…ุน ุฃู†ูˆุงุน ุฒูŠ text, tel, email, url, password, search.
<!-- Validates input against a regular expression -->
<input type="tel" id="phone" name="phone" pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}" required>

step

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุญุฏุฏ ุงู„ุฒูŠุงุฏุฉ ุฃูˆ ุงู„ู†ู‚ุตุงู† ุงู„ู…ุณู…ูˆุญ ุจูŠู‡ุง ููŠ ุงู„ู‚ูŠู…ุฉ ู„ู…ุง ุชุณุชุฎุฏู… ุงู„ุฃุณู‡ู… (ู…ุน type="number") ุฃูˆ ุงู„ู€ slider (ู…ุน type="range").
<!-- Defines the allowed increments for number/range inputs -->
<input type="number" name="points" step="5" min="0" max="50"> <!-- Allowed values: 0, 5, 10... -->

ุนู†ุงุตุฑ ุชุงู†ูŠุฉ ู…ู‡ู…ุฉ ููŠ ุงู„ููˆุฑู…

ุนู†ุตุฑ ุงู„ู€ <select>

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนู…ู„ ู‚ุงูŠู…ุฉ ู…ู†ุณุฏู„ุฉ (drop-down list).
<label for="cars">Choose a car:</label>
<select name="cars" id="cars">
    <!-- Options for the dropdown list -->
    <option value="0">Volvo</option>
    <option value="1">fiat</option>
    <option>lambo</option> <!-- If value is omitted, text content is used -->
    <option>mpw</option>
</select>
  • ุนู†ุตุฑ <option>: ูƒู„ ุนู†ุตุฑ ุฌูˆู‡ ุงู„ู‚ุงูŠู…ุฉ ุจู†ุนุฑูู‡ ุจุงุณุชุฎุฏุงู… <option>.
    • ุงู„ู€ value attribute ู‡ูˆ ุงู„ู‚ูŠู…ุฉ ุงู„ู„ูŠ ู‡ุชุชุจุนุช ู„ู„ุณูŠุฑูุฑ ู„ูˆ ุงู„ูŠูˆุฒุฑ ุงุฎุชุงุฑ ุงู„ู€ option ุฏู‡.
    • ุงู„ู†ุต ุงู„ู„ูŠ ุจูŠู† <option> ูˆ </option> ู‡ูˆ ุงู„ู„ูŠ ุจูŠุธู‡ุฑ ู„ู„ูŠูˆุฒุฑ ููŠ ุงู„ู‚ุงูŠู…ุฉ.
  • ุงู„ุงุฎุชูŠุงุฑ ุงู„ุงูุชุฑุงุถูŠ: ุฃูˆู„ <option> ููŠ ุงู„ู‚ุงูŠู…ุฉ ู‡ูˆ ุงู„ู„ูŠ ุจูŠูƒูˆู† ู…ุฎุชุงุฑ ุงูุชุฑุงุถูŠู‹ุง.
  • ุงู„ู€ selected attribute: ุนุดุงู† ุชุฎู„ูŠ option ู…ุนูŠู† ู‡ูˆ ุงู„ู„ูŠ ู…ุฎุชุงุฑ ุงูุชุฑุงุถูŠู‹ุงุŒ ุถูŠูู„ู‡ ุงู„ู€ selected attribute.
    <option value="fiat" selected>Fiat</option> <!-- This option is pre-selected -->
  • ุงู„ู€ size attribute: ุจูŠุญุฏุฏ ุนุฏุฏ ุงู„ุฎูŠุงุฑุงุช ุงู„ู„ูŠ ุจุชูƒูˆู† ุธุงู‡ุฑุฉ ููŠ ุงู„ู‚ุงูŠู…ุฉ ู…ู† ุบูŠุฑ ู…ุง ุชูุชุญู‡ุง. ู„ูˆ ุฃูƒุจุฑ ู…ู† 1ุŒ ุดูƒู„ู‡ุง ุจูŠุชุบูŠุฑ ู…ู† ู‚ุงูŠู…ุฉ ู…ู†ุณุฏู„ุฉ ู„ู€ list box.
    <!-- Displays 3 options at once -->
    <select id="cars" name="cars" size="3">
        <option value="volvo">Volvo</option>
        <option value="saab">Saab</option>
        <option value="fiat">Fiat</option>
        <option value="audi">Audi</option>
    </select>
  • ุงู„ู€ multiple attribute: ู„ูˆ ุถูุชู‡ุŒ ุจูŠุณู…ุญ ู„ู„ูŠูˆุฒุฑ ูŠุฎุชุงุฑ ุฃูƒุชุฑ ู…ู† option ููŠ ู†ูุณ ุงู„ูˆู‚ุช (ุบุงู„ุจู‹ุง ุนู† ุทุฑูŠู‚ ุงู„ุถุบุท ุนู„ู‰ Ctrl ุฃูˆ Shift ู…ุน ุงู„ูƒู„ูŠูƒ).
    <!-- Allows multiple selections (usually with Ctrl/Shift + click) -->
    <select id="cars" name="cars" size="4" multiple>
        <option value="volvo">Volvo</option>
        <option value="saab">Saab</option>
        <option value="fiat">Fiat</option>
        <option value="audi">Audi</option>
    </select>

ุนู†ุตุฑ ุงู„ู€ <textarea>

  • ุงู„ูˆุธูŠูุฉ: ุจูŠุนู…ู„ ุญู‚ู„ ุฅุฏุฎุงู„ ู†ุตูŠ ู…ุชุนุฏุฏ ุงู„ุฃุณุทุฑ (multi-line input field). ู…ู†ุงุณุจ ู„ู„ู†ุตูˆุต ุงู„ุทูˆูŠู„ุฉ ุฒูŠ ุงู„ุฑุณุงูŠู„ ุฃูˆ ุงู„ุชุนู„ูŠู‚ุงุช.
<!-- Defines the initial visible size -->
<!-- The text between tags is the default value -->
<textarea name="message" rows="10" cols="30">The cat was playing in the garden.</textarea>
  • ุงู„ู€ rows attribute: ุจูŠุญุฏุฏ ุงู„ุงุฑุชูุงุน ุงู„ู…ุจุฏุฆูŠ ู„ู„ุญู‚ู„ ุจุนุฏุฏ ุงู„ุณุทูˆุฑ ุงู„ุธุงู‡ุฑุฉ.
  • ุงู„ู€ cols attribute: ุจูŠุญุฏุฏ ุงู„ุนุฑุถ ุงู„ู…ุจุฏุฆูŠ ู„ู„ุญู‚ู„ ุจุนุฏุฏ ุงู„ุญุฑูˆู ุงู„ุชู‚ุฑูŠุจูŠ ููŠ ุงู„ุณุทุฑ.
  • ู…ู„ุญูˆุธุฉ: ู…ู…ูƒู† ุจุฑุถู‡ ุชุชุญูƒู… ููŠ ุญุฌู… ุงู„ู€ <textarea> ุจุงุณุชุฎุฏุงู… CSS.

ูƒุฏู‡ ูŠุจู‚ู‰ ุบุทูŠู†ุง ู…ุนุธู… ุฃู†ูˆุงุน ุงู„ู€ <input> ุงู„ู…ุดู‡ูˆุฑุฉ ูˆุงู„ู€ attributes ุงู„ู…ู‡ู…ุฉ ุงู„ู„ูŠ ุจู†ุณุชุฎุฏู…ู‡ุง ููŠ ุจู†ุงุก ุงู„ู€ Forms HTML.