Advertisement
vencinachev

HTML-Tag-Validation

Mar 17th, 2021
892
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <title>HTML tag</title>
  5. </head>
  6. <body bgcolor="#99ffcc">
  7.    <h2>HTML вложен двоен таг валидатор</h1>
  8.    <form action="#" method="post">
  9.     <label for="html">HTML тагове: </label>
  10.     <input type="text" name="html">
  11.     <input type="submit" name="validate" value="Валидирай">
  12.    </form>
  13.    <?php
  14.     if (isset($_POST["validate"])){
  15.         $htmlt = $_POST["html"];
  16.         $regEx = "/<([^>]+)>.*<([^>]+)>.*<\/\\2>.*<\/\\1>/";
  17.         if (preg_match($regEx, $htmlt)){
  18.             echo "<p> Валиден </p>";
  19.         } else {
  20.             echo "<p> Невалиден </p>";
  21.         }
  22.     }
  23.    ?>
  24. </body>
  25. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement