dirname-rtl-manual.html (1400B)
1 <!DOCTYPE html> 2 <meta charset=utf-8> 3 <title>Submitting element directionality: the dirname attribute (rtl)</title> 4 <link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org"> 5 <link rel=help href="https://html.spec.whatwg.org/multipage/#submitting-element-directionality:-the-dirname-attribute"> 6 <form action="dirname-rtl-manual.html" method=get> 7 <p><label>User: <input type=text name="user" dirname="user.dir" required></label></p> 8 <p><label>Comment: <textarea name="comment" dirname="comment.dir" required></textarea></label></p> 9 <p><button type=submit>Post Comment</button></p> 10 </form> 11 <p>Switch to a right-to-left writing direction, enter a text in the input and textarea, and submit the form.</p> 12 <p>Test passes if the word "PASS" appears below</p> 13 <script> 14 function getParameterByName(name) { 15 name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); 16 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), 17 results = regex.exec(location.search); 18 return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); 19 } 20 21 var userDir = getParameterByName("user.dir"); 22 var commentDir = getParameterByName("comment.dir"); 23 if (commentDir && userDir) { 24 var p = document.createElement("p"); 25 var success = (commentDir == "rtl" && userDir == "rtl") 26 p.textContent = success ? "PASS" : "FAIL"; 27 document.body.appendChild(p); 28 } 29 </script>