开发者

JavaScript validate then add points on true validation?

开发者 https://www.devze.com 2023-02-26 06:02 出处:网络
I\'m writing a website for a school project and I want to have the user type the answer, have JavaScript validate it, and if it\'s true, add it to a point counter displayed on the top of the page.

I'm writing a website for a school project and I want to have the user type the answer, have JavaScript validate it, and if it's true, add it to a point counter displayed on the top of the page.

How in the world should I go about this?

Is there something in开发者_C百科 particular I should be looking for?


You have to look for:

1) How to access and manipulate the DOM. You need to manipulate the counter value, for example.

2) How to add event listeners, such as onsubmit/onclick for your form.

3) How to do if statements in javascript.


This is how I would do it :

  1. Put Jquery on your site
  2. Add an event listener on the submit field button using Jquery
  3. In the jquery, validate the content
  4. If the content is validated, then change the counter using Jquery and selector

I can give you more info if you give more info. Hope this helps though

0

精彩评论

暂无评论...
验证码 换一张
取 消