1

i am quite new to jQuery and I'm trying to use the lettersonly function for my signup form. I have looked at this question already but implementing it didn't seem to work for me.

Here's my code:

            <form class="kennzeichen-input-big" action="step1.php">
                <input type="text" name="kuerzel" id="kuerzel" style="font-size:50px;" maxlength="3" required> 
                <input type="submit" value="Zur Reservierung" class="btn signup" style="width:auto; margin-top:15px; margin-left:20px;">


</form>

    <script>
        $("form").validate(
        { rules: { ('#kuerzel'): { lettersonly: true } } }
        );
    </script>

I assume the problem is with the "myField" tag? I have tried several things, but didnt get it to work. I did include the additional functions, too.

Community
  • 1
  • 1
RadicalM1nd
  • 147
  • 1
  • 10

1 Answers1

0

All you're missing is that the field must be referenced by it's name attribute in the Validate call.

    $("form").validate(
    { rules: { ('#kuerzel'): { lettersonly: true } } }
    );

Becomes:

    $("form").validate(
    { rules: { kuerzel: { lettersonly: true } } }
    );

That's it, assuming you aren't seeing any other errors on the page...

Ryley
  • 21,046
  • 2
  • 67
  • 81
  • Hi, thanks for the response. I tried that and it didn't help. I'm not seeing any other issues and the general "required" comment works. – RadicalM1nd Nov 30 '15 at 17:28
  • Hard to tell from the information given what's actually wrong then, because it works here: http://jsfiddle.net/ryleyb/cc9yxt2a/ – Ryley Nov 30 '15 at 17:44
  • Maybe there are other forms on the page? And the validate rules are being attached to the wrong one? – Ryley Nov 30 '15 at 17:45
  • Only a single form on the page, I'm pretty much stumped at this point, but i will continue trying. Thanks for the help so far. – RadicalM1nd Nov 30 '15 at 18:12
  • What jQuery script do you use? Additional methoesd isnt working: http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.js Im having a similar issue https://stackoverflow.com/questions/54384682/using-only-one-jquery-validation-script-that-also-supports-addmethod. my sample project https://information-contact.000webhostapp.com/ –  Jan 29 '19 at 00:46