Comments (3)
You are definitely right, you could use it without the given attribute. However, if you want to have data validation out of the box, you would want to include that as well.
from mva-introduction-to-aspnet-mvc.
Hi AnmolRathod1. You are right in that, without the email attribute, input fields will accept email data. However, you could think of it in terms of sets: email input is a subset of general text input. If you know you are collecting just email type data, you would want to narrow the focus. If you are looking for any text input, including email, you would want to leave the attribute off.
One analogy is with fruit, where apple is a subset of fruit:
"I would like a piece of fruit": You could get a banana, an orange, an apple, a pears, etc.
"I would like an apple:" You just get an apple.
It's also worth noting that modern browsers make use of the additional HTML attributes rendered on the page. So you're not just getting the benefit of email validation, but you may also get a more email-focussed on-screen keyboard and other UI benefits when you use the email attribute. Think specifically with tablet PCs and smart phones, where the keyboard is shown on the screen; an email-focussed keyboard may include common domain-name endings (such as .com, .org, etc.) and a prominent "@" symbol.
Finally, you can create your own attributes to do other validation or provide you with client-side hooks for certain fields. If you get into the habit of using the right built-in attributes for the right fields, you will be more likely to add new custom functionality in the Microsoft MVC way, which will make your code more readily usable by others and probably make it easier to develop in the first place.
I hope that helps.
from mva-introduction-to-aspnet-mvc.
@LordScree thank you for your help you explained me in much much easier way and yes it helped me a lot
from mva-introduction-to-aspnet-mvc.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mva-introduction-to-aspnet-mvc.