how to remove "please fill out this field" pop up when click on submit form in angularjs but other validations should work

36,622

Solution 1

Add novalidate attribute to your form to disable browser default validation

For Ex

<form role="form" novalidate id="createForm" v name="createForm"  ng-submit="createAdminGroup(adminGroupData)">

Find more here

Solution 2

Add the attribute formnovalidate inside your submit button:

Example:

<button name="submit" type="submit" formnovalidate class="btn btn-success">Save</button>

This will disable only the browser form validation. You still have the validation from your AngularJS code.

You can see the W3C specification here

I had the same problem a few days ago and that's how I managed to solve

Solution 3

I just tried this and it worked:

oninvalid="this.setCustomValidity(' ')" oninput="this.setCustomValidity('')" >

I have add a space between the two single quotes.

Since i added a bootstrap tooltip on my input fields and required, the invalid input comes to focus and displays the tooltip value.

It was simpler than I thought it would be.

Share:
36,622
Priyanka Maurya
Author by

Priyanka Maurya

Updated on October 19, 2021

Comments

  • Priyanka Maurya
    Priyanka Maurya over 2 years

    I want to remove the "please fill out this field" pop-up as validation and normal validations which are declared should display.

    Html:

    <div class="panel-body">
        <form role="form" id="createForm" v name="createForm"  ng-submit="createAdminGroup(adminGroupData)">
            <div class="form-group" ng-class="{ 'has-error' : createForm.firstName.$invalid && !createForm.firstName.$pristine}">
                <label class="label1">First Name</label>
                <input name="firstName" id="firstName" class="form-control" placeholder="First Name" name="firstName"  type="text" ng-model="adminGroupData.firstName  " required/>
             <span style="color:red" ng-show="createForm.firstName.$invalid  && !createForm.firstName.$pristine">Please enter first name</span>
            </div>
    
            <div class="form-group">
                <label class="label1">Last Name </label>
                <input name="lastName" id="lastName" class="form-control" placeholder="Last Name" name="lastNmae"  type="text" ng-model="adminGroupData.lastName" />
            </div>
    
            <div class="form-group">
                <label class="label1"> Email Id </label>
                <input type="email" name="email" id="email" class="form-control"  placeholder="[email protected]" value=""ng-model="adminGroupData.email"/>
            </div>
            <div class="form-group">
                <label class="label1"> Password </label>
                <input name="password" id="password" class="form-control" placeholder="password"  value=""  ng-model="adminGroupData.password" />
            </div>
    
            <button name="submit" type="submit" class="btn btn-success" id="" ng-disabled="userForm.$invalid">Save</button>
            <button class="btn btn-default" id="cancel" type="button" onclick='handleCancelCreateAdmin()'> Back </button>
    
            </form>
    </div>