and also need the validation code for only digits for cell number. and also if i enter 10 digits along with some more additional characters, it is not showing error message.
See real time code validation and fix errors and warnings of your code as you type.
You can then adapt this form to your own requirements.
Let's build a simple form with a validation script.
But keep in mind that one should not rely only upon Java Script validation. This should be validated on the server side as well.
Here's an example of the above in action: Almost all answers to this questions suggest using Regex to validate emails addresses.
So to start off, create yourself a little HTML file, like this.