开发者

how can i make an javascript object for a HTML form

开发者 https://www.devze.com 2023-01-08 03:01 出处:网络
i want to make an object which can do all the actions my form needs -- it can validate the form, submit the form, and so forth. i want javascript to do all these things. i no longer want to write same

i want to make an object which can do all the actions my form needs -- it can validate the form, submit the form, and so forth. i want javascript to do all these things. i no longer want to write same code several times over in procedural fashion javascript in global namespace. i want to create Javascript object to handle these functions of the form and i want to have everything live in a namespace to avoid conflicts.

i have hard time to understand how javascript OO works compared to other language with classical inheritance vs prototype inheritance. can somebody show me how to create a class, and then instantiate 2 objects开发者_开发知识库 of that class and bind each of them to two identical form on the same page?

i look at module pattern but it seems for singleton only.

thanks if anybody can help


Don't reinvent the wheel. If you want to perform form validation and submit based on validation you can try using jQuery and jQuery validation.

To understand Javascript's prototype-based OO model, there are many resources:

  1. Javascript: The world's most misunderstood programming language (start here - it's by Douglas Crockford)
  2. Introduction to Object Oriented Programming in Javascript (from the Mozilla Developer Center)
0

精彩评论

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

关注公众号