โดย M031 » 20/11/2015 1:34 pm
*** สำหรับการดัก validation ของ HTML5 ต้องประกอบไปด้วย
tag form, required, pattern, title
required = attributes ที่ต้องใส่ลงไปใร tag input
pattern = รูปแบบตัวอักษรหรือตัวเลขหรืออักษรพิเศษ ที่เราต้องการจะกำหนด
title = เปรียบเสมือนข้อความที่แจ้งเตือนหลังจากที่ กรอกข้อมูลผิดรูปแบบที่กำหนด
โค้ด: เลือกทั้งหมด
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML5 Validation</title>
</head>
<body>
<form action="" method="post">
<table>
<tr>
<td>Name </td>
<td><input type="text" placeholder="Name" required pattern="[a-zA-Zก-ุฯ-๙\s]*" title="กรุณากรอกตัวอักษร"></td>
</tr>
<tr>
<td>LastName </td>
<td><input type="text" placeholder="lasrName" required pattern="[a-zA-Zก-ุฯ-๙\s]*" title="กรุณากรอกตัวอักษร"></td>
</tr>
<tr>
<td>Telephone</td>
<td><input type="text" placeholder="lasrName" required pattern="[0-9\s]*" title="กรุณากรอกตัวเลข"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="btnsave" value="Save"></td>
</tr>
</table>
</form>
</body>
</html>
สามารถศึกษาเพิ่มเติ่มได้ที่
http://www.w3schools.com/html/html_form_attributes.asp
ลิ้งที่เกี่ยวข้อง
https://www.mindphp.com/%E0%B8%9A%E0%B8% ... html5.html
*** สำหรับการดัก validation ของ HTML5 ต้องประกอบไปด้วย [b]tag form, required, pattern, title[/b]
[b]required[/b] = attributes ที่ต้องใส่ลงไปใร tag input
[b]pattern [/b]= รูปแบบตัวอักษรหรือตัวเลขหรืออักษรพิเศษ ที่เราต้องการจะกำหนด
[b]title [/b]= เปรียบเสมือนข้อความที่แจ้งเตือนหลังจากที่ กรอกข้อมูลผิดรูปแบบที่กำหนด
[code]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML5 Validation</title>
</head>
<body>
<form action="" method="post">
<table>
<tr>
<td>Name </td>
<td><input type="text" placeholder="Name" required pattern="[a-zA-Zก-ุฯ-๙\s]*" title="กรุณากรอกตัวอักษร"></td>
</tr>
<tr>
<td>LastName </td>
<td><input type="text" placeholder="lasrName" required pattern="[a-zA-Zก-ุฯ-๙\s]*" title="กรุณากรอกตัวอักษร"></td>
</tr>
<tr>
<td>Telephone</td>
<td><input type="text" placeholder="lasrName" required pattern="[0-9\s]*" title="กรุณากรอกตัวเลข"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="btnsave" value="Save"></td>
</tr>
</table>
</form>
</body>
</html>
[/code]
สามารถศึกษาเพิ่มเติ่มได้ที่
http://www.w3schools.com/html/html_form_attributes.asp
ลิ้งที่เกี่ยวข้อง
https://www.mindphp.com/%E0%B8%9A%E0%B8%97%E0%B9%80%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%99%E0%B8%AD%E0%B8%AD%E0%B8%99%E0%B9%84%E0%B8%A5%E0%B8%99%E0%B9%8C/%E0%B8%9A%E0%B8%97%E0%B9%80%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%99-html5.html