Chitika

February 4, 2013

Knockout validation: Сomparison of the two fields

I would like to share how I've solved this problem.

The typical example is a simple registration form with the view model:

    var viewModel = ko.validatedObservable({
        userName: ko.observable().extend({ required: true }),
        password: ko.observable().extend({ required: true }),
        passwordConfirm: ko.observable().extend({ required: true })
    });

Then you can easily check is your viewModel valid using:

    viewModel.isValid();

And it works very good. But you don't have validation are your password and password confirmation fields equal.

To do it you have to add these lines:

    viewModel().password.extend({ equal: viewModel().passwordConfirm });
    viewModel().passwordConfirm.extend({ equal: viewModel().password });

After that you will have client notification as well as ability to check is your view model valid in code (as mentioned above).

That's all.
Good luck.

37 comments:

  1. I just want to say I’m new to blogs and seriously loved this web site. Probably I’m likely to bookmark your blog post . You really have great stories. Regards for revealing your web site.

    Linux Training in Chennai Velachery

    ReplyDelete
  2. Hi,
    I have read your previous posts recently , and let me tell you, your website gives the
    best and the most interesting information. This is just the kind of information that i had
    been looking for.
    Thank you.
    oracle R12 training

    ReplyDelete
  3. I have just read your site, If you are looking for best Oracle financials also giving all software Course Online Training.The oracle Online Training is one of the leading Online Training institute in Hyderabad.
    Oracle fusion financials training

    ReplyDelete
  4. You really did a great job. I found your blog very interesting and very informative. I think your blog is great information source & I like your way of writing and explaining the topics. Keep it up.
    Oracle Fusion HCM Technical Training in Ameerpet

    ReplyDelete
  5. Big Data and Hadoop is an ecosystem of open source components that fundamentally changes the way enterprises store, process, and analyze data.
    hadoop training in bangalore

    ReplyDelete
  6. Thanks for your great and helpful presentation I like your good service.I always appreciate your post.That is very interesting I love reading and I am always searching for informative information like this.Well written article Thank You for Sharing with Us pmp training Chennai | pmp training centers in Chennai | pmp training institutes in Chennai | pmp training and certification in Chennai | pmp training in velachery

    ReplyDelete
  7. Nice post. Thank you for sharing this valuable information.

    ReplyDelete
  8. Very nice post here thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
    machine learning course in Chennai
    machine learning training center in Chennai
    machine learning certification in chennai
    Android training in chennai
    PMP training in chennai

    ReplyDelete
  9. Accord IT Training is providing Best Java Training Institute in Chennai with placement.
    for any queries
    contact on +91 9940289059
    #Java Institute
    #Java Training in chennai
    #Core Java Training in Chennai

    ReplyDelete

  10. I enjoyed over read your blog post. Your blog have nice information, I got good ideas from this amazing blog. I am always searching like this type blog post. I hope I will see again.
    Still Hunting Method
    Hunting psych tips Survival Tips Travel Touring Tips

    ReplyDelete

  11. Thanks for sharing the information. It is very useful for my future. keep sharing
    travel trekking tips
    see the link Tent Camping 101 Exploring Smithriver

    ReplyDelete

  12. Nice Post! Thank you for sharing very good post, it was so Nice to read and useful to improve my knowledge as updated one, keep blogging.
    ASP.Net Training in Electronic City

    ReplyDelete
  13. Thanks for provide great information and looking beautiful blog. If you wish to learn get connected with Advanced Cyber Security Course. I hope below information will help you.
    Ethical Hacking Training in chennai
    Best Training Institute in Chennai

    ReplyDelete
  14. Nice Post. If you wish to get study abroad in any course. The below information will suit you.
    Skolarrssolutions
    Mbbs in Russia
    Mbbs in UK

    ReplyDelete
  15. We at Strive 2 drive,driving school In Melbourne. Driving School in Melbourne!
    is one of the best & safe driving school where you have an ease of access
    to a wide array of special driving features. We are focused at your
    comfort and so we have put together facilities within the site to ensure
    that you get the very best. Driving School in Melbourne!

    ReplyDelete
  16. We develop free teaching aids for parents and educators to teach English to pre-school children. For more info please visit here: English for children

    ReplyDelete
  17. Resurge is absolutely 100% natural, safe and effective. Many thousands of folks enjoy taking Resurge every day and there has been absolutely zero side effects reported. Every capsule of Resurge is manufactured here in the USA in our state of the art FDA approved and GMP (good manufacturing practices) certified facility under the most sterile, strict and precise standards. Resurge is 100% all natural, vegetarian and non-GMO. As always, if you have a medical condition it's recommended to consult with your doctor. Best natural foods for weight loss

    ReplyDelete
  18. Top AWS Online Training Institute In Ameerpet, Hyderabad IntelliQ IT Offers Best Amazon Web Services AWS Classroom and Online Training Course With Real-Time Project.

    ReplyDelete
  19. Really awesome blog!!! I finally found a great post here.I really enjoyed reading this article. Thanks for sharing valuable information. good work
    Ai & Artificial Intelligence Course in Chennai
    PHP Training in Chennai
    Ethical Hacking Course in Chennai Blue Prism Training in Chennai
    UiPath Training in Chennai

    ReplyDelete
  20. I appreciate this piece of useful information. Kshemkari Export Import academy one of the best leading Trade and Training Institute for import and export business, provides the best service in India with expert TeamFor more information visit our site: Export Import Certificate Training

    ReplyDelete
  21. Compre documentos en línea, documentos originales y registrados.
    Acerca de Permisodeespana, algunos dicen que somos los solucionadores de problemas, mientras que otros se refieren a nosotros como vendedores de soluciones. Contamos con cientos de clientes satisfechos a nivel mundial. Hacemos documentos falsos autorizados y aprobados como Permiso de Residencia Español, DNI, Pasaporte Español y Licencia de Conducir Española. Somos los fabricantes y proveedores de primer nivel de estos documentos, reconocidos a nivel mundial.

    Comprar permiso de residencia,
    permiso de residenciareal y falso en línea,
    Compre licencia de conducir en línea,
    Compre una licencia de conducir española falsa en línea,
    Comprar tarjeta de identificación,
    Licencia de conducir real y falsa,
    Compre pasaporte real en línea,

    Visit Here fpr more information. :- https://permisodeespana.com/licencia-de-conducir-espanola/
    Address: 56 Guild Street, London, EC4A 3WU (UK)
    Email: contact@permisodeespana.com
    WhatsApp: +443455280186

    ReplyDelete
  22. You make so many great points here that I read your article a couple of times. Your views are in accordance with my own for the most part. This is great content for your readers. Miraz Tony Denver Jacob dyna Vini Ramos Rahim Mina Taylor

    ReplyDelete
  23. "เว็บที่แจกเยอะที่สุดฝากง่าย ถอนไว ด้วยระบบออโต้

    เว็บพนันออนไลน์เชื่อถือได้ มาแรง เล่นทั้งที ต้องเลือกเว็บเรา คอเกมห้ามพลาด รวบรวมเกมเด็ดจากค่ายดัง เว็บตรงไม่ผ่านเอเย่นต์ เล่นได้ไม่มีเบื่อกับเกม สล็อต คาสิโน กีฬา ครบ เว็บเดียวเล่นได้ทุกเกม สมัคร "

    ReplyDelete
  24. Thanks for sharing with us 🙂
    Sclinbio.com this is my web site

    ReplyDelete
  25. Extremely intriguing to peruse this article.I might want to thank you for the endeavors you had made for composing this marvelous article. This article propelled me to understand more. keep it up. our sclinbio

    ReplyDelete
  26. I found this article very interesting and informative. Thank you for the effort you put into writing this excellent piece. It motivated me to learn more about this topic. Please continue your great work - I look forward to reading more of your insightful articles.

    ReplyDelete
  27. This comment has been removed by the author.

    ReplyDelete
  28. This comment has been removed by the author.

    ReplyDelete