{"id":656,"date":"2017-10-23T13:21:35","date_gmt":"2017-10-23T04:21:35","guid":{"rendered":"http:\/\/www.takaya-com.jp\/archives\/?p=656"},"modified":"2017-10-23T13:21:35","modified_gmt":"2017-10-23T04:21:35","slug":"%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%82%92%e4%bd%bf%e3%82%8f%e3%81%9a%e3%81%ab%e3%83%95%e3%82%a9%e3%83%bc%e3%83%a0%e3%81%ae%e3%82%a8%e3%83%a9%e3%83%bc%e3%83%81%e3%82%a7%e3%83%83%e3%82%af","status":"publish","type":"post","link":"https:\/\/takaya-com.jp\/archives\/2017\/10\/%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%82%92%e4%bd%bf%e3%82%8f%e3%81%9a%e3%81%ab%e3%83%95%e3%82%a9%e3%83%bc%e3%83%a0%e3%81%ae%e3%82%a8%e3%83%a9%e3%83%bc%e3%83%81%e3%82%a7%e3%83%83%e3%82%af\/","title":{"rendered":"\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u308f\u305a\u306b\u30d5\u30a9\u30fc\u30e0\u306e\u30a8\u30e9\u30fc\u30c1\u30a7\u30c3\u30af\u6a5f\u80fd\u3092\u4f5c\u3063\u3066\u307f\u3088\u3046"},"content":{"rendered":"<p><!-- \u672c\u6587 --><\/p>\n<p>JavaScript\u3092\u4f7f\u3063\u3066\u3001\u30d5\u30a9\u30fc\u30e0\u306e\u30a8\u30e9\u30fc\u30c1\u30a7\u30c3\u30af\u6a5f\u80fd\u3092\u642d\u8f09\u3057\u307e\u3057\u3087\u3046\u3002<br \/>\n<!--more--><br \/>\n\u4ee5\u4e0b\u304c\u30b3\u30fc\u30c9\u30b5\u30f3\u30d7\u30eb\u306b\u306a\u308a\u307e\u3059\u3002\u30a8\u30e9\u30fc\u304c\u5168\u3066\u306a\u304f\u306a\u308b\u3068\u9001\u4fe1\u3055\u308c\u308b\u3088\u3046\u306b\u3001html\u306eform\u30bf\u30b0\u306b\u306f\u3001from.php\u3092\u6307\u5b9a\u3057\u3066\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u25bcJavaScript<\/p>\n<pre class=\"lang:js decode:true \" title=\"JavaScript\" >\r\n$(function() {\r\n\t$(\".alert\").hide();\r\n\tvar sendF= true;\r\n\r\n\t$(\"#submitBtn\").click(function(){\r\n\t\tif(!$(\"#text\").val()){\r\n\t\t\t$(\"#tSec .alert\").show();\r\n\t\t\tsendF = false; \r\n\t\t}else{\r\n\t\t\t$(\"#tSec .alert\").hide();\r\n\t\t}\r\n\t\tvar radioC = $('input[name=\"radio\"]:checked').length; \r\n\t\tif(radioC == 0){\r\n\t\t\t$(\"#rSec .alert\").show();\r\n\t\t\tsendF = false; \r\n\t\t}else{\r\n\t\t\t$(\"#rSec .alert\").hide();\r\n\t\t}\r\n\t\tvar checkC = $('input[name=\"checkbox\"]:checked').length; \r\n\t\tif(checkC < 1){\r\n\t\t\t$(\"#cSec .alert\").show();\r\n\t\t\tsendF = false; \r\n\t\t}else{\r\n\t\t\t$(\"#cSec .alert\").hide();\r\n\t\t}\r\n\t\tif($(\"select\").val() == \"none\"){\r\n\t\t\t$(\"#sSec .alert\").show();\r\n\t\t\tsendF = false; \r\n\t\t}else{\r\n\t\t\t$(\"#sSec .alert\").hide();\r\n\t\t}\r\n\t\tif(!$(\"#textarea\").val()){\r\n\t\t\t$(\"#taSec .alert\").show();\r\n\t\t\tsendF = false; \r\n\t\t}else{\r\n\t\t\t$(\"#taSec .alert\").hide();\r\n\t\t}\r\n\t\tif(sendF == false){\r\n\t\t\treturn false; \r\n\t\t}\r\n\r\n\r\n\t});\r\n\r\n});\r\n\r\n<\/pre>\n<p>\u25bcCSS<\/p>\n<pre class=\"lang:css decode:true \" title=\"CSS\" >\r\n<style type=\"text\/css\">\r\nbody{\r\n\t-webkit-font-smoothing: antialiased;\r\n\tbackground:#333333;\r\n}\r\n\r\nmain{\r\n\twidth:1000px;\r\n\tmargin:0 auto 50px;\r\n\tdisplay:block;\r\n}\r\n\r\nh1{\r\n\tcolor:#fff;\r\n\ttext-align:center;\r\n\tfont-size:2em;\r\n\tpadding:30px 0;\r\n\tfont-weight:bold;\r\n}\r\n\r\nmain{\r\n\tbackground:#fff;\r\n\tpadding:50px 40px;\r\n}\r\n\r\nmain div{\r\n\tmargin-bottom:50px;\r\n}\r\n\r\np{\r\n    background-color: #33cc33;\r\n\tfont-size:1.5em;\r\n\tcolor:#333;\r\n\tmargin-bottom:10px;\r\n\tfont-weight:bold;\r\n}\r\n\r\np.alert{\r\n    background-color: transparent;\r\n\tfont-size:1em;\r\n\tfont-weight:normal;\r\n\tmargin:10px 0;\r\n\tcolor:#DC2900;\r\n}\r\n\r\ninput[type=\"text\"], textarea{\r\n\tpadding:5px;\r\n\tfont-size:1em;\r\n\tcolor:#333;\r\n\tborder:1px solid #CCC;\r\n\tbackground:#EFEFEF;\r\n}\r\n\r\ninput[type=\"text\"]{\r\n\twidth:300px;\r\n}\r\n\r\ntextarea{\r\n\twidth:500px;\r\n\theight:200px;\r\n}\r\n\r\n#submitBtn{\r\n\tcolor:#333;\r\n\tbackground:#33cc33;\r\n\tborder:0;\r\n\tborder-radius:30px;\r\n\tdisplay:block;\r\n\tmargin:0 auto;\r\n\tfont-size:1.4em;\r\n\tpadding:10px 25px;\r\n\tfont-weight:bold;\r\n}\r\n\r\n#submitBtn:focus{\r\n\toutline:none;\r\n}\r\n<\/style>\r\n<\/pre>\n<p>\u25bcHTML<\/p>\n<pre class=\"lang:xhtml decode:true \" title=\"HTML\" >\r\n<form action=\"form.php\" method=\"post\">\r\n    <div id=\"tSec\">\r\n      <p><label for=\"text\">\u6587\u7ae0<\/label><\/p>\r\n      <p class=\"alert\">error:\u6587\u7ae0\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\r\n      <input type=\"text\" id=\"text\" name=\"name\" value=\"\">\r\n    <\/div>\r\n    <div id=\"rSec\">\r\n      <p>\u30e9\u30b8\u30aa\u30dc\u30bf\u30f3<\/p>\r\n      <p class=\"alert\">error : \u9078\u629e\u80a2\u306e\u4e2d\u304b\u3089\uff11\u3064\u3092\u9078\u3093\u3067\u304f\u3060\u3055\u3044\u3002<\/p>\r\n      <input type=\"radio\" id=\"radio1\" name=\"radio\" value=\"Radio1\">\r\n      <label for=\"radio1\">\u9078\u629e\u80a21<\/label>\r\n      <input type=\"radio\" id=\"radio2\" name=\"radio\" value=\"Radio2\">\r\n      <label for=\"radio2\">\u9078\u629e\u80a22<\/label>\r\n      <input type=\"radio\" id=\"radio3\" name=\"radio\" value=\"Radio3\">\r\n      <label for=\"radio3\">\u9078\u629e\u80a23<\/label>\r\n    <\/div>\r\n    <div id=\"cSec\">\r\n      <p>\u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9<\/p>\r\n      <p class=\"alert\">error : \uff11\u3064\u4ee5\u4e0a\u306b\u30c1\u30a7\u30c3\u30af\u3092\u5165\u308c\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\r\n      <input type=\"checkbox\" id=\"checkbox1\" name=\"checkbox\" value=\"Checkbox1\">\r\n      <label for=\"checkbox1\">\u30c1\u30a7\u30c3\u30af1<\/label>\r\n      <input type=\"checkbox\" id=\"checkbox2\" name=\"checkbox\" value=\"Checkbox2\">\r\n      <label for=\"checkbox2\">\u30c1\u30a7\u30c3\u30af2<\/label>\r\n      <input type=\"checkbox\" id=\"checkbox3\" name=\"checkbox\" value=\"Checkbox3\">\r\n      <label for=\"checkbox3\">\u30c1\u30a7\u30c3\u30af3<\/label>\r\n      <input type=\"checkbox\" id=\"checkbox4\" name=\"checkbox\" value=\"Checkbox4\">\r\n      <label for=\"checkbox4\">\u30c1\u30a7\u30c3\u30af4<\/label>\r\n    <\/div>\r\n    <div id=\"sSec\">\r\n      <p>\u30bb\u30ec\u30af\u30c8<\/p>\r\n      <p class=\"alert\">error : \u3044\u305a\u308c\u304b\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\r\n      <select>\r\n        <option value=\"none\">---<\/option>\r\n        <option value=\"Select1\">\u30bb\u30ec\u30af\u30c81<\/option>\r\n        <option value=\"Select2\">\u30bb\u30ec\u30af\u30c82<\/option>\r\n        <option value=\"Select3\">\u30bb\u30ec\u30af\u30c83<\/option>\r\n      <\/select>\r\n    <\/div>\r\n    <div id=\"taSec\">\r\n      <p>\r\n        <label for=\"textarea\">\u30c6\u30ad\u30b9\u30c8\u30a8\u30ea\u30a2<\/label>\r\n      <\/p>\r\n      <p class=\"alert\">error : \u6587\u7ae0\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\r\n      <textarea id=\"textarea\" name=\"textarea\"><\/textarea>\r\n    <\/div>\r\n    <input type=\"submit\" value=\"\u5b8c\u4e86\" id=\"submitBtn\">\r\n  <\/form>\r\n<\/pre>\n<p><a href=\"http:\/\/www.takaya-com.jp\/archives\/demo\/validation\/\" target=\"_blank\">\u30c7\u30e2\u30da\u30fc\u30b8\u306f\u3001\u3053\u3061\u3089<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript\u3092\u4f7f\u3063\u3066\u3001\u30d5\u30a9\u30fc\u30e0\u306e\u30a8\u30e9\u30fc\u30c1\u30a7\u30c3\u30af\u6a5f\u80fd\u3092\u642d\u8f09\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/656"}],"collection":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/comments?post=656"}],"version-history":[{"count":1,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/656\/revisions"}],"predecessor-version":[{"id":657,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/656\/revisions\/657"}],"wp:attachment":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/media?parent=656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/categories?post=656"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/tags?post=656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}