ANGULARJS provides rich filling forms and validation. We can use Ng-click to handle ANGULARJS Click button events, and then use the $dirty and $invalid logo to do the verification method. Use the Novalidate form declaration to prohibit any browser-specific validation. form controls use a large number of corner activities. Let's take a quick look at the relevant events first.
Event
ANGULARJS provides multiple events that can be associated with an HTML control. For example, Ng-click is usually associated with a button. The following events are supported by ANGULARJS.
Ng-click
Ng-dbl-click
Ng-mousedown
Ng-mouseup
Ng-mouseenter
Ng-mouseleave
Ng-mousemove
Ng-mouseover
Ng-keydown
Ng-keyup
Ng-keypress
Ng-change
Ng-click
Use the command to click a button to reset the data in the form.
<input name= "FirstName" type= "text" ng-model= "FirstName" required> "<input" name= "LastName" type= "
text" Ng-model= "LastName" required> <input name= "email" type= "email" ng-model= "
Email" required>
< Button ng-click= "reset ()" >Reset</button>
<script>
function Studentcontroller ($scope) {
$scope. reset = function () {
$scope. firstName = "Mahesh";
$scope. LastName = "Parashar";
$scope. email = "MaheshParashar@yiibai.com";
}
$scope. Reset ();
</script>
Validating data
The following tracking error can be used.
$dirty-The specified value has been changed.
$invalid-The state of the value is invalid.
$error-point out the exact error.
Example
The following example shows all of the above instructions.
Testangularjs.html
Output
Open textangularjs.html in a Web browser. See the results below.
The above is the Angularjs form of knowledge collation, follow-up continue to supplement the relevant knowledge, thank you for your support of this site!