how can i make an javascript object for a HTML form
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:
- Javascript: The world's most misunderstood programming language (start here - it's by Douglas Crockford)
- Introduction to Object Oriented Programming in Javascript (from the Mozilla Developer Center)
精彩评论