Suppose you are making a registration form in which you are taking phone numbers of users. Now, You want to ask the user for four alternative contact numbers. You want to make sure that all four contact numbers given by users should be different.
This functionality can be implemented in two ways :
- After submitting form: For this, we can use “onsubmit” or “onclick” event which is also provided by HTML and they work on Buttons. “onclick” event will work for buttons while “onsubmit” event will work for forms
Below examples illustrate the both approaches:
Example 2: In this example, we will show which of the values are same and works dynamically as we change input.
- How to compare Structs with the Different Values Assigned to Data Fields in Golang?
- How to add input fields dynamically on button click in AngularJS ?
- How to detect when an @Input() value changes in Angular?
- How to detect value change on hidden input field in JQuery ?
- How to Access Interface Fields in Golang?
- strings.Fields() Function in Golang With Examples
- Mathematics | Rings, Integral domains and Fields
- Sort array of objects by object fields in PHP
- Scala | Controlling visibility of constructor fields
- Mapping external values to dataframe values in Pandas
- Difference between private keyword and private fields in TypeScript
- How to detect the change in DIV's dimension ?
- How to detect Browser Language in PHP?
- How to detect a mobile device using PHP?
- How to Detect if Someone's Stealing Your WiFi?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.