<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="https://notiz.blog/wp-content/plugins/pretty-feeds/pretty-feed-v4.xsl" type="text/xsl" media="screen" ?>


<!--

	Feeds whisper secrets,
	In the RSS Club's embrace,
	Knowledge blooms in grace.

-->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:source="http://source.scripting.com/"
xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>

<channel>
	<title>child theme &#8211; notizBlog</title>
	<atom:link href="https://notiz.blog/tag/child-theme/feed/" rel="self" type="application/rss+xml" />
	<link>https://notiz.blog</link>
	<description>a weblog mainly about the open, portable, interoperable, small, social, synaptic, semantic, structured, distributed, (re-)decentralized, independent, microformatted and federated social web</description>
	<lastBuildDate>Tue, 28 Sep 2021 21:22:11 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://notiz.blog/wp-content/uploads/2019/10/cropped-notizblog-icon-1-32x32.png</url>
	<title>child theme &#8211; notizBlog</title>
	<link>https://notiz.blog</link>
	<width>32</width>
	<height>32</height>
</image> 
<source:blogroll>https://reader.pfefferle.org/i/?a=opml&amp;get=c_2</source:blogroll>
<creativeCommons:license>https://creativecommons.org/licenses/by-sa/4.0/</creativeCommons:license>
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/>
<atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/>
<atom:link rel="hub" href="https://switchboard.p3k.io/"/>
<atom:link rel="self" href="https://notiz.blog/tag/child-theme/feed/"/>
<atom:link rel="search" type="application/opensearchdescription+xml" title="Search notizBlog" href="https://notiz.blog/wp-api/opensearch/1.1/document" />	<item>
		<title>HTML5, Input-Types, Form-Validierung und WordPress</title>
		<link>https://notiz.blog/2011/07/11/html5-input-types-form-validierung-und-wordpress/</link>
					<comments>https://notiz.blog/2011/07/11/html5-input-types-form-validierung-und-wordpress/#comments</comments>
		
		<dc:creator><![CDATA[Matthias Pfefferle]]></dc:creator>
		<pubDate>Mon, 11 Jul 2011 18:46:37 +0000</pubDate>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[child theme]]></category>
		<category><![CDATA[FediBlog]]></category>
		<category><![CDATA[hCard]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[input-types]]></category>
		<category><![CDATA[Plugin]]></category>
		<guid isPermaLink="false">http://notizblog.org/?p=3840</guid>

					<description><![CDATA[Dass HTML5 ein paar neue input-types definiert, habe ich durch die hcard-input-brainstorming so am Rande auf geschnappt, mir aber nichts weiter dabei gedacht&#8230; Durch Zufall bin ich heute aber über folgenden Tweet von Sylvia Egger gestoßen: Just implemented native #HTML5 form validation on #wp comments form &#8211; it&#x27; quite simple &#38; should be in #wp [&#8230;]]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image alignright" style="max-width:50%"><img decoding="async" src="https://notiz.blog/wp-content/uploads/2011/07/HTML5_Logo_256.png" alt="HTML5 Logo" /></figure>



<p>Dass HTML5 ein paar neue input-types definiert, habe ich durch die <a href="http://microformats.org/wiki/hcard-input-brainstorming#HTML5_input_types">hcard-input-brainstorming</a> so am Rande auf geschnappt, mir aber nichts weiter dabei gedacht&#8230; Durch Zufall bin ich heute aber über folgenden <a href="http://twitter.com/sprungmarkers/status/90305500108947457">Tweet</a> von Sylvia Egger gestoßen:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
    <p>Just implemented native <a rel="tag" class="hashtag u-tag u-category" href="https://notiz.blog/tag/html5/">#HTML5</a> form validation on #wp comments form &#8211; it&#x27; quite simple &amp; should be in #wp default theme</p>
</blockquote>



<p>und habe bissle recherchiert&#8230; Mit den neuen Input-Types ist es doch tatsächlich möglich Input-Felder über den Browser validieren zu lassen&#8230; Ich bin begeistert! 🙂</p>



<p>Trägt man beispielsweise eine Nicht-Email-Adresse in folgendes Feld&#8230;</p>


<pre class="wp-block-code"><span><code class="hljs language-xml"><span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"email"</span> /&gt;</span></code></span></pre>


<p>bekommt man&#8230;</p>



<figure class="wp-block-image aligncenter"><img decoding="async" src="https://notiz.blog/wp-content/uploads/2011/07/firefox-email-validation.jpg" alt="Email Validation im Firefox" /></figure>



<p>Schön wenn man sich noch über solche Kleinigkeiten freuen kann oder 😉</p>



<p>Lange rede kurzer Sinn: Da WordPress alle Formulare an zentraler Stelle definiert, ist es ziemlich einfach sie mit ein paar neuen Input-Types zu versehen. Mit dem folgenden Code wird das Kommentar-Formular mit den Typen &quot;email&quot; und &quot;url&quot; und das Suchformular mit dem Typ &quot;search&quot; (funktioniert nur in den WebKit-Browsern) erweitert:</p>



<p><ins><strong>Code-Update</strong>: <a href="https://yatil.de/">Eric Eggert</a> hat mich in den <a href="https://notiz.blog/2011/07/11/html5-input-types-form-validierung-und-wordpress/#comment-173210">Kommentaren</a> darauf hingewiesen, dass man mit <code>&lt;input required /&gt;</code> auch noch die Pflichtfelder validieren kann. Danke!</ins></p>



<p><ins><strong>Code-Update 2</strong>: Dank <a href="https://www.im-tal.net">maxe</a> werden jetzt auch die WordPress Settings berücksichtigt (Comment author must fill out name and e-mail) und das &quot;Comment&quot;-Feld ist natürlich auch <code>required</code></ins></p>


<pre class="wp-block-code"><span><code class="hljs language-xml"><span class="php"><span class="hljs-meta">&lt;?php</span>
<span class="hljs-comment">/*
Plugin Name: html5 input-types
Plugin URI: https://notiz.blog/
Description: Adds the new HTML5 input-types to WordPress' default forms
Version: 0.1
Author: pfefferle
Author URI: https://notiz.blog/
*/</span>

add_filter(<span class="hljs-string">"comment_form_default_fields"</span>, <span class="hljs-string">"change_comment_input_types"</span>);

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">change_comment_input_types</span><span class="hljs-params">($fields)</span> </span>{
  <span class="hljs-keyword">if</span> (get_option(<span class="hljs-string">"require_name_email"</span>, <span class="hljs-keyword">false</span>)) {
    $fields&#91;<span class="hljs-string">'author'</span>] = preg_replace(<span class="hljs-string">'/&lt;input/'</span>, <span class="hljs-string">'&lt;input required'</span>, $fields&#91;<span class="hljs-string">'author'</span>]);
    $fields&#91;<span class="hljs-string">'email'</span>] = preg_replace(<span class="hljs-string">'/"text"/'</span>, <span class="hljs-string">'"email" required'</span>, $fields&#91;<span class="hljs-string">'email'</span>]);
  } <span class="hljs-keyword">else</span> {
    $fields&#91;<span class="hljs-string">'email'</span>] = preg_replace(<span class="hljs-string">'/"text"/'</span>, <span class="hljs-string">'"email"'</span>, $fields&#91;<span class="hljs-string">'email'</span>]);
  }

  $fields&#91;<span class="hljs-string">'url'</span>] = preg_replace(<span class="hljs-string">'/"text"/'</span>, <span class="hljs-string">'"url"'</span>, $fields&#91;<span class="hljs-string">'url'</span>]);

  <span class="hljs-keyword">return</span> $fields;
}

add_filter(<span class="hljs-string">"get_search_form"</span>, <span class="hljs-string">"change_search_form_input_types"</span>);

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">change_search_form_input_types</span><span class="hljs-params">($form)</span> </span>{
  <span class="hljs-keyword">return</span> preg_replace(<span class="hljs-string">'/"text"/'</span>, <span class="hljs-string">'"search"'</span>, $form);
}

add_filter(<span class="hljs-string">"comment_form_field_comment"</span>, <span class="hljs-string">"change_comment_field_input_types"</span>);

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">change_comment_field_input_types</span><span class="hljs-params">($field)</span> </span>{
  <span class="hljs-keyword">return</span> preg_replace(<span class="hljs-string">'/&lt;textarea/'</span>, <span class="hljs-string">'&lt;textarea required'</span>, $field);
}
<span class="hljs-meta">?&gt;</span></span></code></span></pre>


<p>Funktioniert als Plugin und in Child-Themes (einfach in die <code>functions.php</code> kopieren).</p>



<p>Danke auch an <a href="https://marcgoertz.de/">Marc Görtz</a> der mich über <a href="http://twitter.com/dreamseer">Twitter</a> reichlich mit Links zu dem Thema versorgt hat:</p>



<ul class="wp-block-list">
    <li><a href="https://web.archive.org/web/20200724153910/http://diveintohtml5.info/forms.html">A Form of Madness (den hab ich selber gefunden)</a></li>
    <li><a href="https://web.archive.org/web/20110307142356/http://html5pattern.com/">HTML5 Pattern</a></li>
    <li><a href="https://web.archive.org/web/20100629022438/http://flowplayer.org/tools/demos/validator/index.html">Fallback jQuery Validator</a></li>
</ul>



<p>Testen könnt ihr das übrigens hier auf notiz.blog.</p>
<p>Congratulations on being an RSS reader! You are part of an elite group of people who know how to stay updated in style.</p>]]></content:encoded>
					
					<wfw:commentRss>https://notiz.blog/2011/07/11/html5-input-types-form-validierung-und-wordpress/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
	</channel>
</rss>
