HTML ထည့်သွင်းမှု အမျိုးအစားများ
<input>
ဤအခန်းသည် HTML ဒြပ်စင် အတွက် မတူညီသောအမျိုးအစားများကို ဖော်ပြသည် ။
HTML ထည့်သွင်းမှု အမျိုးအစားများ
ဤသည်မှာ HTML တွင် သင်သုံးနိုင်သော မတူညီသော ထည့်သွင်းမှုအမျိုးအစားများဖြစ်သည်-
<input type="button">
<input type="checkbox">
<input type="color">
<input type="date">
<input type="datetime-local">
<input type="email">
<input type="file">
<input type="hidden">
<input type="image">
<input type="month">
<input type="number">
<input type="password">
<input type="radio">
<input type="range">
<input type="reset">
<input type="search">
<input type="submit">
<input type="tel">
<input type="text">
<input type="time">
<input type="url">
<input type="week">
အကြံပြုချက်- ရည်ညွှန်းချက် ၏ မူရင်းတန်ဖိုးမှာ type
"စာသား" ဖြစ်သည်။
စာသားရိုက်ထည့်ပါ။
<input type="text">
တစ်ကြောင်းတည်းသော စာသားထည့်သွင်းမှုအကွက် ကို သတ်မှတ်သည် -
ဥပမာ
<form>
<label for="fname">First name:</label><br>
<input
type="text" id="fname" name="fname"><br>
<label for="lname">Last
name:</label><br>
<input type="text" id="lname" name="lname">
</form>
ဤသည်မှာ browser တစ်ခုတွင် အထက်ဖော်ပြပါ HTML ကုဒ်ကို မည်သို့ပြသမည်နည်း။
နာမည်:မျိုးနွယ်အမည်:
Password ရိုက်ထည့်ပါ။
<input type="password">
စကားဝှက်အကွက် ကို သတ်မှတ်သည် -
ဥပမာ
<form>
<label for="username">Username:</label><br>
<input type="text"
id="username" name="username"><br>
<label for="pwd">Password:</label><br>
<input type="password" id="pwd" name="pwd">
</form>
ဤသည်မှာ browser တစ်ခုတွင် အထက်ဖော်ပြပါ HTML ကုဒ်ကို မည်သို့ပြသမည်နည်း။
အသုံးပြုသူအမည်-စကားဝှက်-
စကားဝှက်အကွက်ရှိ ဇာတ်ကောင်များကို မျက်နှာဖုံးစွပ်ထားသည် (ကြယ်ပွင့်များ သို့မဟုတ် စက်ဝိုင်းများအဖြစ် ပြထားသည်)။
ထည့်သွင်းမှုအမျိုးအစား Submit
<input type="submit">
ဖောင်ဒေ တာကို ဖောင်ကိုင်တွယ်သူ ထံ ပေးပို့ရန် ခလုတ်တစ်ခုကို သတ်မှတ်သည် ။
form-handler သည် ပုံမှန်အားဖြင့် input data ကိုလုပ်ဆောင်ရန်အတွက် script တစ်ခုပါရှိသော server page တစ်ခုဖြစ်သည်။
ဖောင်ပုံစံကိုင်တွယ်သူအား ဖောင်၏ရည်ညွှန်းချက်တွင် action
သတ်မှတ်ထားသည်-
ဥပမာ
<form action="/action_page.php">
<label for="fname">First
name:</label><br>
<input type="text" id="fname" name="fname"
value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</form>
ဤသည်မှာ browser တစ်ခုတွင် အထက်ဖော်ပြပါ HTML ကုဒ်ကို မည်သို့ပြသမည်နည်း။
ပေးပို့ရန် ခလုတ်၏ တန်ဖိုး ရည်ညွှန်းချက်ကို သင် ချန်လှပ်ထားပါက၊ ခလုတ်သည် မူရင်းစာသားကို ရရှိလိမ့်မည်-
ဥပမာ
<form action="/action_page.php">
<label for="fname">First
name:</label><br>
<input type="text" id="fname" name="fname"
value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit">
</form>
ထည့်သွင်းမှုအမျိုးအစားကို ပြန်လည်သတ်မှတ်ပါ။
<input type="reset">
ပုံစံတန်ဖိုးအားလုံးကို ၎င်းတို့၏ မူရင်းတန်ဖိုးများအဖြစ် ပြန်လည်သတ်မှတ်ပေးမည့် ပြန်လည်သတ်မှတ်ရန် ခလုတ်ကို သတ်မှတ်သည် -
ဥပမာ
<form action="/action_page.php">
<label for="fname">First
name:</label><br>
<input type="text" id="fname" name="fname"
value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
<input type="reset">
</form>
ဤသည်မှာ browser တစ်ခုတွင် အထက်ဖော်ပြပါ HTML ကုဒ်ကို မည်သို့ပြသမည်နည်း။
ထည့်သွင်းတန်ဖိုးများကို ပြောင်းလဲပြီးနောက် "ပြန်လည်သတ်မှတ်မည်" ခလုတ်ကို နှိပ်ပါက၊ ဖောင်ဒေတာကို မူရင်းတန်ဖိုးများအဖြစ် ပြန်လည်သတ်မှတ်မည်ဖြစ်သည်။
ထည့်သွင်းမှု ရေဒီယို
<input type="radio">
ရေဒီယိုခလုတ်ကို သတ်မှတ်သည် ။
ရေဒီယိုခလုတ်များသည် အသုံးပြုသူတစ်ဦးအား ကန့်သတ်အရေအတွက်ရွေးချယ်မှုတစ်ခုမှ တစ်ခုကိုသာ ရွေးချယ်ခွင့်ပေးသည်-
ဥပမာ
<p>Choose your favorite Web language:</p>
<form>
<input type="radio" id="html" name="fav_language"
value="HTML">
<label for="html">HTML</label><br>
<input
type="radio" id="css" name="fav_language" value="CSS">
<label
for="css">CSS</label><br>
<input type="radio" id="javascript"
name="fav_language" value="JavaScript">
<label for="javascript">JavaScript</label>
</form>
ဤသည်မှာ browser တစ်ခုတွင် အထက်ဖော်ပြပါ HTML ကုဒ်ကို မည်သို့ပြသမည်နည်း။
Input Type Checkbox
<input type="checkbox">
checkbox ကိုသတ်မှတ်သည် ။
Checkboxes သည် အသုံးပြုသူတစ်ဦးအား ရွေးချယ်မှုအရေအတွက်ကန့်သတ်ထားသည့် ZERO သို့မဟုတ် MORE ရွေးချယ်မှုများကို ရွေးချယ်ခွင့်ပေးသည်။
ဥပမာ
<form>
<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
<label for="vehicle1"> I have a bike</label><br>
<input
type="checkbox" id="vehicle2" name="vehicle2" value="Car">
<label for="vehicle2">
I have a car</label><br>
<input type="checkbox"
id="vehicle3" name="vehicle3"
value="Boat">
<label for="vehicle3"> I have a boat</label>
</form>
ဤသည်မှာ browser တစ်ခုတွင် အထက်ဖော်ပြပါ HTML ကုဒ်ကို မည်သို့ပြသမည်နည်း။
Input Type ခလုတ်
<input type="button">
ခလုတ် တစ်ခုကို သတ်မှတ်သည် -
ဥပမာ
<input type="button" onclick="alert('Hello World!')" value="Click Me!">
ဤသည်မှာ browser တစ်ခုတွင် အထက်ဖော်ပြပါ HTML ကုဒ်ကို မည်သို့ပြသမည်နည်း။
Input Type Color
အရောင် <input type="color">
တစ်ခုပါရှိသင့်သော input အကွက်များအတွက်အသုံးပြုသည်။
ဘရောင်ဇာပံ့ပိုးမှုပေါ်မူတည်၍ အရောင်ရွေးချယ်မှုတစ်ခုသည် ထည့်သွင်းမှုအကွက်တွင် ပေါ်လာနိုင်သည်။
ဥပမာ
<form>
<label for="favcolor">Select your favorite
color:</label>
<input type="color" id="favcolor" name="favcolor">
</form>
ထည့်သွင်းသည့်ရက်စွဲအမျိုးအစား
ရက်စွဲပါရှိသင့် သော <input type="date">
ထည့်သွင်းကွက်လပ်များအတွက် အသုံးပြုသည်။
ဘရောင်ဇာပံ့ပိုးမှုပေါ်မူတည်၍ ရက်စွဲရွေးချယ်မှုတစ်ခုသည် ထည့်သွင်းမှုအကွက်တွင် ပေါ်လာနိုင်သည်။
ဥပမာ
<form>
<label for="birthday">Birthday:</label>
<input
type="date" id="birthday" name="birthday">
</form>
ရက်စွဲများအတွက် ကန့်သတ်ချက်များထည့်ရန် min
နှင့် attribute များကိုလည်း သင်အသုံးပြုနိုင်ပါသည် -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
<input type="datetime-local">
အချိန်ဇုန်မရှိသော ရက်စွဲနှင့် အချိန်ထည့်သွင်းမှုအကွက်ကို သတ်မှတ်သည် ။
ဘရောင်ဇာပံ့ပိုးမှုပေါ်မူတည်၍ ရက်စွဲရွေးချယ်မှုတစ်ခုသည် ထည့်သွင်းမှုအကွက်တွင် ပေါ်လာနိုင်သည်။
ဥပမာ
<form>
<label for="birthdaytime">Birthday (date and
time):</label>
<input type="datetime-local" id="birthdaytime" name="birthdaytime">
</form>
Email ရိုက်ထည့်ပါ။
<input type="email">
အီးမေးလ်လိပ်စာတစ်ခုပါရှိသင့်သော ထည့်သွင်းကွက်လပ်များအတွက် အသုံးပြုသည် ။
ဘရောက်ဆာပံ့ပိုးမှုပေါ် မူတည်၍ ပေးပို့သည့်အခါ အီးမေးလ်လိပ်စာကို အလိုအလျောက် အတည်ပြုနိုင်သည်။
အချို့သောစမတ်ဖုန်းများသည် အီးမေးလ်အမျိုးအစားကို မှတ်မိကြပြီး အီးမေးလ်ထည့်သွင်းမှုနှင့် ကိုက်ညီစေရန် ကီးဘုတ်တွင် ".com" ကို ထည့်ပါ။
ဥပမာ
<form>
<label for="email">Enter your email:</label>
<input type="email" id="email" name="email">
</form>
ထည့်သွင်းရန် ဖိုင်အမျိုးအစား
ဖိုင်ကိုရွေးချယ် သည့် <input type="file">
အကွက်နှင့် ဖိုင်အပ်လုဒ်များအတွက် "Browse" ခလုတ်ကို သတ်မှတ်သည်။
ဥပမာ
<form>
<label for="myfile">Select a file:</label>
<input type="file" id="myfile" name="myfile">
</form>
Input Type Hidden
ဝှက်ထားသော ထည့်သွင်းမှုအကွက် ကို <input type="hidden">
သတ်မှတ်သည် (အသုံးပြုသူတစ်ဦးမှ မမြင်နိုင်)။
ဝှက်ထားသော အကွက်တစ်ခုသည် ဖောင်တစ်ခုတင်သွင်းသောအခါတွင် အသုံးပြုသူများမှ မမြင်နိုင် သို့မဟုတ် မပြုပြင်နိုင်သော ဒေတာကို ဝဘ်ဆော့ဖ်ဝဲရေးသားသူများအား ထည့်သွင်းခွင့်ပြုသည်။
ဝှက်ထားသောအကွက်သည် ဖောင်တင်သည့်အခါ အပ်ဒိတ်လုပ်ရန် လိုအပ်သည့် ဒေတာဘေ့စ်မှတ်တမ်းကို သိမ်းဆည်းလေ့ရှိသည်။
မှတ်ချက်- စာမျက်နှာ၏ အကြောင်းအရာတွင် အသုံးပြုသူအား တန်ဖိုးကို မပြသသော်လည်း မည်သည့်ဘရောက်ဆာ၏ developer ကိရိယာများ သို့မဟုတ် "View Source" လုပ်ဆောင်ချက်ကို အသုံးပြု၍ ၎င်းကို မြင်နိုင် (နှင့် တည်းဖြတ်နိုင်သည်)။ လုံခြုံရေးပုံစံအဖြစ် လျှို့ဝှက်ထည့်သွင်းမှုများကို မသုံးပါနှင့်။
ဥပမာ
<form>
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<input
type="hidden" id="custId" name="custId" value="3487">
<input
type="submit" value="Submit">
</form>
Input Type လ
အသုံးပြုသူ <input type="month">
သည် တစ်လနှင့် တစ်နှစ်ကို ရွေးချယ်ခွင့်ရှိသည်။
ဘရောင်ဇာပံ့ပိုးမှုပေါ်မူတည်၍ ရက်စွဲရွေးချယ်မှုတစ်ခုသည် ထည့်သွင်းမှုအကွက်တွင် ပေါ်လာနိုင်သည်။
ဥပမာ
<form>
<label for="bdaymonth">Birthday (month and
year):</label>
<input type="month" id="bdaymonth" name="bdaymonth">
</form>
နံပါတ်ရိုက်ထည့်ပါ။
ကိန်း
ဂဏာန်း ထည့်သွင်းမှုအကွက် <input type="number">
ကို သတ်မှတ်သည် ။
You can also set restrictions on what numbers are accepted.
The following example displays a numeric input field, where you can enter a value from 1 to 5:
Example
<form>
<label for="quantity">Quantity (between 1 and
5):</label>
<input type="number" id="quantity" name="quantity"
min="1" max="5">
</form>
Input Restrictions
Here is a list of some common input restrictions:
Attribute | Description |
---|---|
checked | Specifies that an input field should be pre-selected when the page loads (for type="checkbox" or type="radio") |
disabled | Specifies that an input field should be disabled |
max | Specifies the maximum value for an input field |
maxlength | Specifies the maximum number of character for an input field |
min | Specifies the minimum value for an input field |
pattern | Specifies a regular expression to check the input value against |
readonly | Specifies that an input field is read only (cannot be changed) |
required | Specifies that an input field is required (must be filled out) |
size | Specifies the width (in characters) of an input field |
step | Specifies the legal number intervals for an input field |
value | Specifies the default value for an input field |
You will learn more about input restrictions in the next chapter.
The following example displays a numeric input field, where you can enter a value from 0 to 100, in steps of 10. The default value is 30:
Example
<form>
<label for="quantity">Quantity:</label>
<input
type="number" id="quantity" name="quantity" min="0" max="100" step="10"
value="30">
</form>
Input Type Range
The <input type="range">
defines a control for entering a number whose exact value is not important (like a slider control). Default
range is 0 to 100. However, you can set restrictions on what
numbers are accepted with the min
, max
, and step
attributes:
Example
<form>
<label for="vol">Volume (between 0 and 50):</label>
<input type="range" id="vol" name="vol" min="0" max="50">
</form>
Input Type Search
The <input type="search">
is used for search fields (a search field behaves like a regular text field).
Example
<form>
<label for="gsearch">Search Google:</label>
<input type="search" id="gsearch" name="gsearch">
</form>
Input Type Tel
The <input type="tel">
is used for input fields that should contain a telephone number.
Example
<form>
<label for="phone">Enter your phone number:</label>
<input type="tel" id="phone" name="phone"
pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}">
</form>
Input Type Time
The <input type="time">
allows the user to select a time (no time zone).
Depending on browser support, a time picker can show up in the input field.
Example
<form>
<label for="appt">Select a time:</label>
<input type="time" id="appt" name="appt">
</form>
Input Type Url
The <input type="url">
is used for input fields that should contain a URL address.
Depending on browser support, the url field can be automatically validated when submitted.
Some smartphones recognize the url type, and adds ".com" to the keyboard to match url input.
Example
<form>
<label for="homepage">Add your homepage:</label>
<input type="url" id="homepage" name="homepage">
</form>
Input Type Week
The <input type="week">
allows the user to select a week and year.
Depending on browser support, a date picker can show up in the input field.
Example
<form>
<label for="week">Select a week:</label>
<input type="week" id="week" name="week">
</form>
HTML Exercises
HTML Input Type Attribute
Tag | Description |
---|---|
<input type=""> | Specifies the input type to display |