|
| 1 | +<html lang="en"> |
| 2 | + |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8" /> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <title>PyScript Test</title> |
| 7 | + <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" /> |
| 8 | + <script defer src="https://pyscript.net/alpha/pyscript.js"></script> |
| 9 | + <script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,line-clamp"></script> |
| 10 | +</head> |
| 11 | + |
| 12 | +<body> |
| 13 | + <header> |
| 14 | + <h1 class="text-3xl font-bold underline"> |
| 15 | + PyScript Sample Page |
| 16 | + </h1> |
| 17 | + </header> |
| 18 | + <main> |
| 19 | + <div class="prose"> |
| 20 | + <p> |
| 21 | + <section> |
| 22 | + |
| 23 | + <h1>Check if interger</h1> |
| 24 | + </div> |
| 25 | + <div> |
| 26 | + <input id="InputFieldValueBox" class="border flex-1 mr-3 border-gray-300 p-2 rounded" type="text"> |
| 27 | + <button id="new-task-btn" class="p-2 text-white bg-blue-600 border border-blue-600 rounded" type="submit" pys-onclick="check_if_interger"> |
| 28 | + Check |
| 29 | + </button> |
| 30 | + </div> |
| 31 | + |
| 32 | + <label id='sum'></label> |
| 33 | + </div> |
| 34 | + |
| 35 | + |
| 36 | + </section> |
| 37 | + </p> |
| 38 | + <p> |
| 39 | + If you want to get more information, please click <a href="https://github.com/pyscript/pyscript/blob/main/GETTING-STARTED.md" target="_blank" rel="noopener noreferrer">this link</a>. |
| 40 | + </p> |
| 41 | + |
| 42 | + |
| 43 | + <py-script> |
| 44 | +# Selecting JS element for Value / Text |
| 45 | +Input_Value_Box = Element("InputFieldValueBox") |
| 46 | + |
| 47 | + # Needs an argument passed - don't ask me why! |
| 48 | +def check_if_interger(test): |
| 49 | + |
| 50 | + # Getting The Value Of The Text |
| 51 | + input_text = Input_Value_Box.element.value |
| 52 | + |
| 53 | + |
| 54 | + if input_text.isnumeric(): |
| 55 | + pyscript.write('sum',input_text + " is a interger") |
| 56 | + |
| 57 | + else: |
| 58 | + pyscript.write('sum',input_text + " is not a interger") |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + </py-script> |
| 65 | + </div> |
| 66 | + </main> |
| 67 | + <footer> |
| 68 | + <a href="github.com/MarketingPipeline">©️2022 github.com/MarketingPipeline</a> |
| 69 | + </footer> |
| 70 | +</body> |
| 71 | + |
| 72 | +</html> |
0 commit comments