顯示具有 HTML5 標籤的文章。 顯示所有文章
顯示具有 HTML5 標籤的文章。 顯示所有文章

2022年5月10日 星期二

[研究][ASP.NET]TextBox / input 限填正整數、0、或不填寫的 HTML5 屬性測試

[研究][ASP.NET]TextBox / input 限填正整數、0、或不填寫的 HTML5 屬性測試

2022-05-10

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C#

********************************************************************************

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" 
    CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" type="number" runat="server"></asp:TextBox><br />
        <asp:TextBox ID="TextBox2" type="number" min="0" runat="server"></asp:TextBox><br />
        <asp:TextBox ID="TextBox3" type="number" min="0" step="1" runat="server"></asp:TextBox><br />
        <asp:Button ID="Button1" runat="server" Text="Send" OnClick="Button1_Click" /><br />
        <asp:Label ID="Label1" runat="server"></asp:Label><br />
        <asp:Label ID="Label2" runat="server"></asp:Label><br />
        <asp:Label ID="Label3" runat="server"></asp:Label><br />
    </form>
</body>
</html>


測試狀況

(下圖) 填寫的時候可以填非整數或負數

(下團) 按下 Send 按鈕後才進行檢查,不是整數會被拒絕



(下圖) 不填是允許的

結論:使用 type="number" min="0" 可達到 限填正整數、0、或不填寫。

註:在某個專案,這招無效,不知道受到甚麼CODE或套件干擾。

********************************************************************************

最大值測試

Int64 是有符號 64 位整數數據類型,相當於 C++ 中的 long long、 C# 中的 long 和 SQL Server 中的 bigint,表示值介於 -2^63 ( -9,223,372,036,854,775,808) 到2^63-1(+9,223,372,036,854,775,807 )之間的整數。

敝人把前面加上1當最大值限制測試

<asp:TextBox ID="TextBox3" type="number" min="0" step="1" 
    max="19223372036854775807" runat="server"></asp:TextBox><br /> 

測試




疑似 19223372036854775807 超過 Int64,被當成科學記號浮點數處理,最大值變成 192233720368547758e+19,尾2數換成99,檢查會通過,表示會先換成科學記號,再比是否符合。

結果:數字若超過 Int64,會先換成科學記號,再比是否符合。

(完)

相關

2022年4月24日 星期日

[研究][HTML5][CSS3]placeholder-shown偽類實現輸入框浮動文字效果

[研究][HTML5][CSS3]浮動標籤 (Floating labels)

[研究][HTML5][CSS3]placeholder-shown偽類實現輸入框浮動文字效果

2022-04-24

HTML5 + CSS3

<head>
<style>
.LoginForm {
            padding: 10px;
            width: 500px;
            border: 4px solid #1199CD;
            margin-right: auto;
            margin-left: auto;
            background-color: #FFF;
            margin-bottom: 30px;
            border-radius: 12px;
            overflow: auto;
        }

.input-group {
  position: relative;
  margin: 20px;
  font-size: 16px;
}

.input-group>input {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 1em;
  font-size: 16px;
  line-height: 1.0;
  border: none; 
  border-bottom: 1px solid #cdcdcd;
  border-radius: 0.4em;
  transition: box-shadow 0.3s;
}

.input-group input::placeholder {
  font-style: italic;
  color: #cdcdcd;
}

.input-group>input:focus {
  outline: none;
  box-shadow: 0.2em 0.8em 1.6em #cdcdcd;
}

.input-group>label {
  position: absolute;
  bottom: 0;
  left: 1em;
  z-index: -1;

  visibility: hidden;
  color: #555555;
  opacity: 0;

  -webkit-transform-origin: 0 0;
  transform-origin: 0 0;
  -webkit-transform: translate3d(0, 0, 0) scale(0);
  transform: translate3d(0, 0, 0) scale(0);
  -webkit-transition:
    opacity 0.3s,
    visibility 0.3s,
    transform 0.3s,
    z-index 0.3s;

  transition:
    opacity 0.3s,
    visibility 0.3s,
    transform 0.3s,
    z-index 0.3s;
}

.input-group>input:focus ~ label {
  z-index: 1;
  visibility: visible;
  opacity: 1;
  -webkit-transform: translate3d(0, -2.4em, 0) scale(1);
  transform: translate3d(0, -2.4em, 0) scale(1);
}
</style>
</head>
<form id="form1" runat="server" class="LoginForm">
<h1 style="text-align:center">管理平台</h1><hr>
<div class="input-group">
  <input type="text" id="username" placeholder="請輸入賬號">
  <label for="username">賬號</label>
</div>
<!-- 密碼 -->
<div class="input-group">
  <input type="text" id="password" placeholder="請輸入6~8位密碼">
  <label for="password">密碼</label>
</div>

<div class="input-group">
  <input type="text" id="password" placeholder="驗證碼">
  <label style="z-index: 1;
  visibility: visible;
  opacity: 1;
  -webkit-transform: translate3d(0, -2.4em, 0) scale(1);
  transform: translate3d(0, -2.4em, 0) scale(1);" for="password">驗證碼</label>
</div>
<div class="input-group">
  <input type="submit" value="登入">
</div>
</form>

(完)



2022年4月12日 星期二

[研究][ASP.NET]HTML5 的 input 標籤的 type 屬性的 日期、月曆測試

[研究][ASP.NET]HTML5 的 input 標籤的 type 屬性的 日期、月曆測試

2022-04-12

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C#

HTML Standard
https://html.spec.whatwg.org/multipage/input.html#the-input-element

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" 
    Inherits="WebApplication1.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            datetime-local:
            <asp:TextBox ID="TextBox1" Type="datetime-local" runat="server"></asp:TextBox><br />
            datetime:
            <asp:TextBox ID="TextBox2" Type="datetime" runat="server"></asp:TextBox><br />
            date:
            <asp:TextBox ID="TextBox3" Type="date" runat="server"></asp:TextBox><br />
            time:
            <asp:TextBox ID="TextBox4" Type="time" runat="server"></asp:TextBox><br />
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /><br />
            <asp:Label ID="Label1" runat="server"></asp:Label><br />
            <asp:Label ID="Label2" runat="server"></asp:Label><br />
            <asp:Label ID="Label3" runat="server"></asp:Label><br />
            <asp:Label ID="Label4" runat="server"></asp:Label><br />
        </div>
    </form>
</body>
</html>
 

Default.aspx.cs

using System;

namespace WebApplication1
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Label1.Text = TextBox1.Text;
            Label2.Text = TextBox2.Text;
            Label3.Text = TextBox3.Text;
            Label4.Text = TextBox4.Text;
        }
    }
}

(下圖)執行結果(Chrome 100)

(下圖) Type="datetime-local"

(下圖) Type="datetime"


其中 datetime-local 輸入的結果 2202-04-12T07:45有個英文字母 T,和一般習慣不同,待會測試看看寫入資料庫會變成甚麼。

如果選擇 22022/4/12 下午 02:48,會顯示 2022-04-12T14:48,仍使用英文字母 T。

********************************************************************************

寫入資料庫測試

Default2.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default2.aspx.cs" Inherits="WebApplication1.Default2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:TestDB5ConnectionString %>" 
                DeleteCommand="DELETE FROM [Table1] WHERE [SN] = @SN" 
                InsertCommand="INSERT INTO [Table1] ([date1], [date2], [date3], [date4]) VALUES (@date1, @date2, @date3, @date4)" 
                SelectCommand="SELECT * FROM [Table1]" 
                UpdateCommand="UPDATE [Table1] SET [date1] = @date1, [date2] = @date2, [date3] = @date3, [date4] = @date4 WHERE [SN] = @SN">
                <DeleteParameters>
                    <asp:Parameter Name="SN" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="date1" Type="DateTime" />
                    <asp:Parameter Name="date2" Type="DateTime" />
                    <asp:Parameter Name="date3" Type="DateTime" />
                    <asp:Parameter Name="date4" Type="DateTime" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="date1" Type="DateTime" />
                    <asp:Parameter Name="date2" Type="DateTime" />
                    <asp:Parameter Name="date3" Type="DateTime" />
                    <asp:Parameter Name="date4" Type="DateTime" />
                    <asp:Parameter Name="SN" Type="Int32" />
                </UpdateParameters>
            </asp:SqlDataSource>
            <asp:ListView ID="ListView1" runat="server" DataKeyNames="SN" 
                DataSourceID="SqlDataSource1" InsertItemPosition="LastItem">
                <AlternatingItemTemplate>
                    <tr style="">
                        <td>
                            <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="刪除" />
                            <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="編輯" />
                        </td>
                        <td>
                            <asp:Label ID="SNLabel" runat="server" Text='<%# Eval("SN") %>' />
                        </td>
                        <td>
                            <asp:Label ID="date1Label" runat="server" Text='<%# Eval("date1") %>' />
                        </td>
                        <td>
                            <asp:Label ID="date2Label" runat="server" Text='<%# Eval("date2") %>' />
                        </td>
                        <td>
                            <asp:Label ID="date3Label" runat="server" Text='<%# Eval("date3") %>' />
                        </td>
                        <td>
                            <asp:Label ID="date4Label" runat="server" Text='<%# Eval("date4") %>' />
                        </td>
                    </tr>
                </AlternatingItemTemplate>
                <EditItemTemplate>
                    <tr style="">
                        <td>
                            <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="更新" />
                            <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="取消" />
                        </td>
                        <td>
                            <asp:Label ID="SNLabel1" runat="server" Text='<%# Eval("SN") %>' />
                        </td>
                        <td>
                            <asp:TextBox ID="date1TextBox" runat="server" Text='<%# Bind("date1") %>' />
                        </td>
                        <td>
                            <asp:TextBox ID="date2TextBox" runat="server" Text='<%# Bind("date2") %>' />
                        </td>
                        <td>
                            <asp:TextBox ID="date3TextBox" runat="server" Text='<%# Bind("date3") %>' />
                        </td>
                        <td>
                            <asp:TextBox ID="date4TextBox" runat="server" Text='<%# Bind("date4") %>' />
                        </td>
                    </tr>
                </EditItemTemplate>
                <EmptyDataTemplate>
                    <table runat="server" style="">
                        <tr>
                            <td>未傳回資料。</td>
                        </tr>
                    </table>
                </EmptyDataTemplate>
                <InsertItemTemplate>
                    <tr style="">
                        <td>
                            <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="插入" />
                            <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="清除" />
                        </td>
                        <td>&nbsp;</td>
                        <td>
                            <asp:TextBox ID="date1TextBox" Type="datetime-local" runat="server" Text='<%# Bind("date1") %>' />
                        </td>
                        <td>
                            <asp:TextBox ID="date2TextBox" Type="datetime" runat="server" Text='<%# Bind("date2") %>' />
                        </td>
                        <td>
                            <asp:TextBox ID="date3TextBox" Type="date" runat="server" Text='<%# Bind("date3") %>' />
                        </td>
                        <td>
                            <asp:TextBox ID="date4TextBox" Type="time" runat="server" Text='<%# Bind("date4") %>' />
                        </td>
                    </tr>
                </InsertItemTemplate>
                <ItemTemplate>
                    <tr style="">
                        <td>
                            <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="刪除" />
                            <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="編輯" />
                        </td>
                        <td>
                            <asp:Label ID="SNLabel" runat="server" Text='<%# Eval("SN") %>' />
                        </td>
                        <td>
                            <asp:Label ID="date1Label" runat="server" Text='<%# Eval("date1") %>' />
                        </td>
                        <td>
                            <asp:Label ID="date2Label" runat="server" Text='<%# Eval("date2") %>' />
                        </td>
                        <td>
                            <asp:Label ID="date3Label" runat="server" Text='<%# Eval("date3") %>' />
                        </td>
                        <td>
                            <asp:Label ID="date4Label" runat="server" Text='<%# Eval("date4") %>' />
                        </td>
                    </tr>
                </ItemTemplate>
                <LayoutTemplate>
                    <table runat="server">
                        <tr runat="server">
                            <td runat="server">
                                <table id="itemPlaceholderContainer" runat="server" border="0" style="">
                                    <tr runat="server" style="">
                                        <th runat="server"></th>
                                        <th runat="server">SN</th>
                                        <th runat="server">date1</th>
                                        <th runat="server">date2</th>
                                        <th runat="server">date3</th>
                                        <th runat="server">date4</th>
                                    </tr>
                                    <tr id="itemPlaceholder" runat="server">
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr runat="server">
                            <td runat="server" style="">
                                <asp:DataPager ID="DataPager1" runat="server">
                                    <Fields>
                                        <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" />
                                    </Fields>
                                </asp:DataPager>
                            </td>
                        </tr>
                    </table>
                </LayoutTemplate>
                <SelectedItemTemplate>
                    <tr style="">
                        <td>
                            <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="刪除" />
                            <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="編輯" />
                        </td>
                        <td>
                            <asp:Label ID="SNLabel" runat="server" Text='<%# Eval("SN") %>' />
                        </td>
                        <td>
                            <asp:Label ID="date1Label" runat="server" Text='<%# Eval("date1") %>' />
                        </td>
                        <td>
                            <asp:Label ID="date2Label" runat="server" Text='<%# Eval("date2") %>' />
                        </td>
                        <td>
                            <asp:Label ID="date3Label" runat="server" Text='<%# Eval("date3") %>' />
                        </td>
                        <td>
                            <asp:Label ID="date4Label" runat="server" Text='<%# Eval("date4") %>' />
                        </td>
                    </tr>
                </SelectedItemTemplate>
            </asp:ListView>
        </div>
    </form>
</body>
</html>


Default2.aspx.cs 沒有進行編寫。

(下圖)執行結果(Chrome 100)





其中 datetime-local 選擇 2202-04-12 上午 07:57 寫入資料庫變成 2202-04-12 07:57:00.000。

其中 datetime 手動輸入(沒月曆可選) 2202-04-12 07:57 寫入資料庫變成 2202-04-12 07:57:00.000。

其中 date  2202-04-12 寫入資料庫變成 2202-04-12 07:57:00.000。(自動加上時間了)

其中 time  07:57 寫入資料庫變成 2202-04-12 07:57:00.000。(自動加上日期了)

********************************************************************************

ASP.NET + SQL  Server + 防 SQL Injection 的參數化查詢

因為字母T關係,字串要做一下取代動作 換成一個半型空白字元,否則會出錯。

TextBox1.Text.Replace("T", " ")

********************************************************************************

2022-06-20 補,「新增」模式OK,但不太合適用於「編輯」模式,值無法顯示



********************************************************************************

(完)

相關

[研究]HTML5 的 input 標籤的 type 屬性的 日期、月曆測試
https://shaurong.blogspot.com/2022/04/html5-input-type_12.html

[研究]HTML5 的 input 標籤的 type 屬性的各種值
https://shaurong.blogspot.com/2022/04/html5-input-type.html

[研究][ASP.NET]jQuery 3.6.0 物件沒有支援這個屬性或方法 'datepicker'
https://shaurong.blogspot.com/2022/03/aspnetjquery-360-datepicker.html

[研究][ASP.NET][JavaScript]jQuery.UI.Combined.1.13.1 的 datepicker 與 jQuery 3.6.0 相容測試https://shaurong.blogspot.com/2022/03/aspnetjqueryuicombined1131-datepicker.html

[研究][JavaScript] jQuery Date and Time picker 2.4.5 (jquery-datetimepicker)(NuGet 安裝)
https://shaurong.blogspot.com/2018/03/javascript-jquery-date-and-time-picker.html

[研究][ASP.NET][JavaScript] Bootstrap V3 Datetimepicker 4.17.45 月曆 套件 安裝與試用https://shaurong.blogspot.com/2018/03/bootstrap-v3-datepicker-41745.html

[研究][ASP.NET][JavaScript] Bootstrap Datepicker 1.7.1 月曆 套件 安裝與試用https://shaurong.blogspot.com/2018/03/bootstrap-datepicker-171.html

[研究][ASP.NET][JavaScript] jQuery UI v1.12.1 的 Datepicker 月曆 套件 安裝與試用https://shaurong.blogspot.com/2017/07/jquery-ui-datepicker.html



[研究]HTML5 的 input 標籤的 type 屬性的各種值

[研究]HTML5的input標籤的type屬性的各種值

2022-04-12

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C#

HTML Standard
https://html.spec.whatwg.org/multipage/input.html#the-input-element

Default.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <form>
        HTML5的input標籤的type屬性的各種值:<br \>
        <br \>
        button:<input type="button"><br \>
        checkbox:<input type="checkbox"><br \>
        color:<input type="color"><br \>
        date:<input type="date"><br \>
        datetime:<input type="datetime"><br \>
        datetime-local:<input type="datetime-local"><br \>   
        email:<input type="email"><br \>
        file:<input type="file"><br \>
        hidden:<input type="hidden"><br \>
        image:<input type="image"><br \>
        month:<input type="month"><br \>
        number:<input type="number"><br \>
        password:<input type="password"><br \>
        radio:<input type="radio"><br \>
        range:<input type="range"><br \>
        reset:<input type="reset"><br \>
        search:<input type="search"><br \>
        tel:<input type="tel"><br \>
        text:<input type="text"><br \>
        time:<input type="time"><br \>
        url:<input type="url"><br \>
        week:<input type="week"><br \>
        subimt:<input type="submit"><br \>
    </form>
</body>
</html>


(下圖)執行結果(Chrome 100)

(下圖)執行結果(Edge v100)

(下圖)執行結果(FireFox v99)


(下圖)執行結果(IE11)



********************************************************************************

 <input type="值"> 在 HTML5 多了一些輸入限制功能可方便使用。


button 可點擊的按鈕(通常與 JavaScript 一起使用來啟動腳本)。

checkbox 核取方塊。

color (HTML5) 拾色器。

date (HTML5)  date 控件(包括年、月、日,不包括時間)。

datetime (HTML5)  date 和 time 控件(包括年、月、日、時、分、秒、幾分之一秒,基於 UTC 時區)。

datetime-local (HTML5)  date 和 time 控件(包括年、月、日、時、分、秒、幾分之一秒,不帶時區)。

email (HTML5) 用於 e-mail 地址的字段。

file 文件選擇字段和 "瀏覽..." 按鈕,供文件上傳。

hidden 隱藏輸入字段。

image 圖像作為提交按鈕。

month (HTML5)  month 和 year 控件(不帶時區)。

number (HTML5) 用於輸入數字的字段。

password 密碼字段(字段中的字符會被遮蔽)。

radio 單選按鈕。

range (HTML5) 用於精確值不重要的輸入數字的控件(比如 slider 控件)。

reset 重置按鈕(重置所有的表單值為預設值值)。

search (HTML5) 用於輸入搜索字符串的文本字段。

submit 提交按鈕。

tel (HTML5) 用於輸入電話號碼的字段。

text 預設值。一個單行的文本字段(預設值寬度為 20 個字符)。

time (HTML5) 用於輸入時間的控件(不帶時區)。

url (HTML5) 用於輸入 URL 的字段。

week (HTML5)  week 和 year 控件(不帶時區)。

(完)

相關

[研究]HTML5 的 input 標籤的 type 屬性的各種值
https://shaurong.blogspot.com/2022/04/html5-input-type.html

[研究]HTML5必填欄位檢查 required
https://shaurong.blogspot.com/2022/04/html5-required.html

[研究][ASP.NET][JavaScript]離開填寫欄位時,檢查必填並彈出alert對話盒視窗
https://shaurong.blogspot.com/2022/04/aspnetjavascriptalert.html

[研究] NuGet 對 jQuery.Validation 1.19.2 安裝測試
https://shaurong.blogspot.com/2020/08/nuget-jqueryvalidation-1192.html

[研究]HTML5必填欄位檢查 required

[研究]HTML5必填欄位檢查 required

2022-04-12、2023-01-18

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C#

發現 HTML5 本身就有必填欄位檢查的屬性 required,或寫成 required="required"

<%@ Page Language="C#" AutoEventWireup="true" 
    CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:TextBox ID="TextBox1" runat="server" required></asp:TextBox><br />
            <asp:TextBox ID="TextBox2" runat="server" required="required"></asp:TextBox><br />
            <asp:Button ID="Button1" runat="server" Text="Button" />
        </div>
    </form>
</body>
</html>


(下圖) 執行後,按下按鈕,若未填寫會跳出「請填寫這個欄位」(Chrome、Edge)、「這是必要欄位」(IE11)、「請填此欄位」(FireFox)

**********

另外 <input type="值"> 在 HTML5 多了一些輸入限制功能可方便使用。


button 可點擊的按鈕(通常與 JavaScript 一起使用來啟動腳本)。

checkbox 核取方塊。

color (HTML5) 拾色器。

date (HTML5) date 控件(包括年、月、日,不包括時間)。

datetime (HTML5) date 和 time 控件(包括年、月、日、時、分、秒、幾分之一秒,基於 UTC 時區)。

datetime-local (HTML5) date 和 time 控件(包括年、月、日、時、分、秒、幾分之一秒,不帶時區)。

email (HTML5) 用於 e-mail 地址的字段。

file 文件選擇字段和 "瀏覽..." 按鈕,供文件上傳。

hidden 隱藏輸入字段。

image 圖像作為提交按鈕。

month (HTML5) month 和 year 控件(不帶時區)。

number (HTML5) 用於輸入數字的字段。

password 密碼字段(字段中的字符會被遮蔽)。

radio 單選按鈕。

range (HTML5) 用於精確值不重要的輸入數字的控件(比如 slider 控件)。

reset 重置按鈕(重置所有的表單值為預設值值)。

search (HTML5) 用於輸入搜索字符串的文本字段。

submit 提交按鈕。

tel (HTML5) 用於輸入電話號碼的字段。

text 預設值。一個單行的文本字段(預設值寬度為 20 個字符)。

time (HTML5) 用於輸入時間的控件(不帶時區)。

url (HTML5) 用於輸入 URL 的字段。

week (HTML5) week 和 year 控件(不帶時區)。

********************************************************************************

2023-01-18 補充,在 DetailView 控制項中使用  required="required" ,無效,檢查 HTML Source,插入按鈕是

<a id="MainContent_DetailsView1_LinkButton1" href="javascript:__doPostBack(&#39;ctl00$MainContent$DetailsView1$LinkButton1&#39;,&#39;&#39;)">插入</a>

不知是否因為這個關係。

********************************************************************************

(完)

相關

[研究]HTML5必填欄位檢查 required
https://shaurong.blogspot.com/2022/04/html5-required.html

[研究][ASP.NET][JavaScript]離開填寫欄位時,檢查必填並彈出alert對話盒視窗
https://shaurong.blogspot.com/2022/04/aspnetjavascriptalert.html

[研究] NuGet 對 jQuery.Validation 1.19.2 安裝測試
https://shaurong.blogspot.com/2020/08/nuget-jqueryvalidation-1192.html