Writing Tutorials a Sample JavaScript form Validation New



When it comes to create website, validation might considered as one of the crucial aspect. Websites upon JavaScript form submit often used validation features. Why the website owners want to include the validation feature? Validation is highly required to make sure whether the users using the website are the same person you think they were. Submit form that use JavaScript uses different types of validations. Here are some types of validation that commonly used on submit form.
Types of Validation on JavaScript Form Submit
1.      Number validation
The JavaScript number validation is mostly used to confirm telephone number. It can also be used to confirm security measure to protect the website from the bots. As the name suggests, the entry data for this form is only number. Since now letter or words are included, the coding from JavaScript should be performed easier. The regular expression used for number 0-9 is (/^[0-9]+$/). This expression is exclusively for numbers.
2.      Password validation
The JavaScript function for validating password is rather complicated. Password contains combination of letters and numbers. Each website has their respective standard of password. Some of them require particular amount of characters. Meanwhile, the rests require the password to be combination of letter, number, and special character. The expression used to validate password of 7-16 characters with underscore and numeric digit is ^[A-Za-z]\w{7,15]$.
3.      Username validation
Most people think that JavaScript code for validating user name is simple. The difficulty of expression used on this JavaScript function is completely determined by the standard used for the website. Normally, the website requires the user name to be letters only. This makes the expression simpler than if the user name should be combination of letter and numbers. If the username is only required specific amount of letter, the expression should be something like this (/^[A-Za-z]+$/).
4.      Address validation
Address validation is the least favorite validation used most website. There is a good reason for this. Compared to previous validation, the standard for correct address is vague. In some country, people put the number before the road, while the rests put it after. The main question here is why the website owner requires address validation. If they just want to confirm the address is an actual location, then they can use third party software instead. The JavaScript code for validating user address for this function is too complicated.
5.      Email validation
Compared to previous validation, the JavaScript email validation is mostly used in website. Email consists of personal information and domain. Both of them are separated by the @ symbol. The personal information consists of uppercase, lowercase, numbers, and special character. Meanwhile, the domain contains letters, numbers, dots, and hyphens. The common expression used for it is /^\w-/+([\.-]?\w+)*@w+([\.-]?\w{2,3})+$/.
6.      Gender validation
Gender validation is unique JavaScript function. Instead of using the usual form, it takes advantage of radio button. Radio button means that the user can only select one option. The JavaScript code for validating gender is rather long, yet still able to maintain its simplistic form. It uses the following expression ((form.gender[0].checked==false)&&(form.gender[1].checked==false)){alert(“Select gender”).
SHARE

About andy

I made this blog just to make about the science that I learned during the study, if there is something wrong please comment below, and do not forget to share, thank you.

    Blogger Comment
    Facebook Comment

0 komentar:

Posting Komentar