-3

I am new to regular expressions so I was wondering if anyone got an idea of how you would add a regex that doesn't allow a number that's negative and over a 100 in my element for numbers in a form.

This is my HTML code for the form:

<main class="ispis">
        <div id="pogreska">
        <form method="POST" action=" https://spider.foi.hr/OWT/materijali/ispis_forme.php" novalidate>
            <fieldset class="odjeljak">
                <legend>Prijava:</legend>
                <label for="ime" id="imeLabela">Ime:</label>
                <input type="text" id="ime" required placeholder="Ime"> <br>

                <br><label for="prezime" id="prezimeLabela">Prezime:</label>
                <input type="text" id="prezime" required placeholder="Prezime"> <br>

                <br> <label for="godine"> Vaša dob: </label>
                <input type="number" id="godine" max="100" value="1" min="1" required><br>

                <p> Spol:</p>
                <input type="radio" class="odabir" id="m" name="spol" value="m" checked>
                <label for="m"> M </label>
                <input type="radio" class="odabir" id="z" name="spol" value="ž">
                <label for="z"> Ž </label>
                <br>

                <br><label for="rodenje" id="kalendarLabela">Datum i vrijeme rođenja:</label>
                <input type="datetime-local" id="rodenje" name="rodenje"> <br>

                <br><label for="email" id="emailLabela">Vaš e-mail:</label>
                <input type="email" id="email" required placeholder="ii@gmail.com"> <br>

                <br><label for="lozinka" id="lozinkaLabela">Lozinka:</label>
                <input type="password" id="lozinka" name="lozinka" minlength="6"> <br>

                <br><label for="broj" id="kontaktLabela">Vaš kontakt:</label>
                <input type="tel" id="broj" name="phone" placeholder="091-000-000"> <br>

                <br><label for="visina">Vaša visina: </label>
                80<input type="range" id="visina" name="visina" min="80" max="240">240 <br>

                <br><label for="tezina">Vaša težina: </label>
                <input type="number" id="tezina" min="1" value="1"> <br>
            </fieldset>

            <div id="nevidljiviElement">
                <fieldset id="odjeljak2">
                    <legend>Iskustvo i cilj:</legend>
                    <label for="opis" id="opisLabela">Napišite svoj najdraži trenutak filma:</label> <br>
                    <textarea id="opis" name="Opis" rows="10" cols="40" maxlength="1000" class="grupa_unosa2"></textarea> <br>

                    <p> Odaberite najdraži dio filma: </p>
                    <input type="radio" class="odabir2" id="cijelo" name="plan" value="Cijelo tijelo" required>
                    <label for="cijelo"> Gospodar prstenova: Prstenova družina </label>
                    <br>
                    <input type="radio" class="odabir2" id="gornji" name="plan" value="Gornji dio">
                    <label for="gornji"> Gospodar prstenova: Dvije kule </label>
                    <br>
                    <input type="radio" class="odabir2" id="donji" name="plan" value="Donji dio" checked>
                    <label for="donji"> Gospodar prstenova: Povratak kralja </label>
                    <br>
                    <input type="radio" class="odabir2" id="cardio" name="plan" value="Cardio">
                    <label for="cardio"> Niti jedan dio mi se nije svidio </label>
                    <br>


                    <br> <label for="aktivnost">Odaberite najdražeg lika iz filma: </label>
                    <select id="aktivnost" name="aktivnost" multiple>
                        <optgroup label="Vaša aktivnost do sada">
                            <option value="nije" id="neaktivan">Frodo Baggins</option>
                            <option value="malo">Smeagoll</option>
                            <option value="srednje">Gandalf</option>
                            <option value="mnogo">Aragorn</option>
                            <option value="vrijeme">Arwen</option>
                        </optgroup>

                        <optgroup label="Vaš cilj">
                            <option value="kilogrami" id="izgubiti">Eowyn</option>
                            <option value="misici">Legolas</option>
                            <option value="kondicija">Peregrin Took</option>
                            <option value="snaga">Gimli</option>
                            <option value="fleksibilnost">Gujoslov</option>
                        </optgroup>
                    </select>
                    <br> <br>
                    <p>Vaš cjelokupni dojam o filmu:</p>
                    <input class="checkk" type="checkbox" name="iskustvo[]" value="iskustvo" id="pocetnik">Film je savršen<br>
                    <input class="checkk" type="checkbox" name="iskustvo[]" value="iskustvo">Film je jako dobar<br>
                    <input class="checkk" type="checkbox" name="iskustvo[]" value="iskustvo">Film mi se nije pretjerano svidjeo<br>
                    <input class="checkk" type="checkbox" name="iskustvo[]" value="iskustvo" id="strucnjak">Film je katastrofa<br>
                </fieldset>
            </div>

            <fieldset id="odjeljak3">
                <legend>Poništi ili pošalji</legend>
                <input class="Neprint glow-button" type="reset" value="Poništi"><br>
                <input class="Neprint glow-button" type="submit" value="Pošalji" id="potvrdi">
            </fieldset>
        </form>
    </div>

Also a regex for a textbox which allows 100 - 1000 characters, doesn't allow “,’,<,>, and doesn't allow 2 full stops one after another.

Is there any page that I can try out my regex codes for future coding?

Exch
  • 1
  • 3
  • Why not use `type="number"` with the `min` and `max` attributes? – Barmar May 25 '22 at 17:32
  • There are a number of regexp testing sites. I use regex101.com, there's also regexr.com and regexpal.com – Barmar May 25 '22 at 17:34
  • @Barmar Thank you for the sites! One more question, can you just give me an example of how would you implement a regex (how would you write it) so i have like an idea of how i need to write it? And how would you connect it to a certain part of my form from index.html? – Exch May 25 '22 at 17:46
  • I gave you a link to a question that shows how to do it, aren't the examples there sufficient? – Barmar May 25 '22 at 17:47
  • You do it in the HTML with `` – Barmar May 25 '22 at 17:47

0 Answers0