MOTOSHARE 🚗🏍️
Turning Idle Vehicles into Shared Rides & Earnings

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Owners earn. Renters ride.
🚀 Everyone wins.

Start Your Journey with Motoshare

Registration Form Validation Using Javascript

There are two methods for validating a form

  1. Using a keyword “validate” inside the input tag (<input type=”text” name=”userid” placeholder= “User-Id” size=”20″ required />).

This Will present output as:-

This will present error output as “! Please fill out the field

Complete code for the above form is shared below :-

Presented output for the above operation :-

2. Using function call we need to define a function that will validate the field data and return corresponding errors.

We need to write the html code for input field in the form

<form><label><b> User-Id</b>  </label>   <input type=”text” name=”userid” placeholder= “User-Id” size=”20″ id=”userId” /> <p id=”error1″></p></form>

First we need to call the function on submit of form as (<form name=”myForm”  onsubmit=”return validateForm()” methord=”post”>) Then we need to define the function

This would produce output as

Complete code for the above function is shared below :-

Conclusion:- Validating a form in javascript is easy and is done with the function call and displays an error with respect to the type of input in the field.

abhishek k
0 0 votes
Article Rating
Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
trackback

[…] Let’s see an example for User form validation in JavaScript. click here. […]

1
0
Would love your thoughts, please comment.x
()
x