Simple form validation error - Returns error . $(...).valid is not a function
hi guys
I am trying to get a simple form validation and added my jquery scripts to my asp.net core razor pages. But getting an error
what is wrong here
My script
- $(document).ready(function () {
- $('#Main').show();
- $('#Wait').hide();
- $('#Add_Submit').on("click", function (e) {
- e.preventDefault();
- var form = $('#Add_Form');
- // form.validate();
- if ($('#Add_Form').valid()) {//Valid
- alert('1 says -' + form.valid());
- // form.focusInvalid();
- return false;
- Dawn(data);
- }
- else
- {//INVALID
- alert('2 says -' + form.valid());
- form.focusInvalid();
- }
finally here is my html page
- <form id="Add_Form" action="/Users/Address_Add" method="post">
- <br />
-
-
- <div class="form-group">
- <label class="control-label" for="Username">Username</label>
- <input required class="form-control" maxlength="15" type="text" data-val="true" data-val-length="The field Username must be a string with a minimum length of 6 and a maximum length of 50." data-val-length-max="50" data-val-length-min="6" data-val-required="Please enter your chosen Username" id="Username" name="Username" value="" />
- <span class="text-danger field-validation-valid" data-valmsg-for="Username" data-valmsg-replace="true"></span>
- </div>
- <div class="form-group">
- <label class="control-label" data-val-required="“Message”" for="First_Name">First Name</label>
- <input required class="form-control" maxlength="50" type="text" data-val="true" data-val-length="The field First_Name must be a string with a minimum length of 2 and a maximum length of 50." data-val-length-max="50" data-val-length-min="2" data-val-required="Please enter the first name" id="First_Name" name="First_Name" value="" />
- <span class="text-danger field-validation-valid" data-valmsg-for="First_Name" data-valmsg-replace="true"></span>
- </div>
- <div class="form-group">
- <label class="control-label" for="Last_Name">Last Name</label>
- <input required class="form-control" maxlength="50" type="text" data-val="true" data-val-length="The field Last_Name must be a string with a minimum length of 2 and a maximum length of 50." data-val-length-max="50" data-val-length-min="2" data-val-required="Please enter the last name" id="Last_Name" name="Last_Name" value="" />
- <span class="text-danger field-validation-valid" data-valmsg-for="Last_Name" data-valmsg-replace="true"></span>
- </div>
- <div class="form-group">
- <label class="control-label" for="Mobile">Mobile</label>
- <input required class="form-control" maxlength="15" type="tel" id="Mobile" name="Mobile" value="" />
- <span class="text-danger field-validation-valid" data-valmsg-for="Mobile" data-valmsg-replace="true"></span>
- </div>
- <br />
- <hr />
- <br />
- <div class="form-group">
- <input type="submit" id="Add_Submit" value="Go !" class="btn" />
- </div>
- <br />
- <hr />
- <br />
- </form>