Login validation with jQuery remote |
[eluser]Omaplie[/eluser]
Hi, I have a trouble using the plug-in jQuery validate. What I have done so far is to use the method « remote » to try if a email is already use. JS : Code: $(".inscrip").validate({ Code: private function email_exists() And it works fine ! What I would like to do is the same but with the login. The user enter his username and after he enter his password. If the password is not right, there is a error message. The difference with the « email check » is that with the login I need to get the input of the username and compare the password of this username with the password entered by the user. I tried a lot but nothing work. I hope you can help me. Thank you a lot.
[eluser]rthut[/eluser]
Try this: Code: $(".inscrip").validate({
[eluser]Omaplie[/eluser]
Hi, The « check email system » works fine. What I would like to do is the same but to check the login. Here is a screen : http://dl.dropbox.com/u/8088222/exp.png In the first field you choose a name and to each name match a password. If the password doesn't match with the name, there is a error message. I have done something like that but it doesn't work : JS: Code: $(".inscrip").validate({ And in the controller : Code: <?php Thank you very much for your help. I hope you can help me, I get a stuck. Thank you a lot.
[eluser]CroNiX[/eluser]
It would be much more efficient (and a lot simpler code-wise), imo, to just serialize and send the form with the ajax request and return the form validation errors, if any, from CI instead of an ajax call for each individual rule.
[eluser]Omaplie[/eluser]
Hi, Sorry for this late answer. You say it's better don't use the jQuery Validate plugin ?
[eluser]CroNiX[/eluser]
I just think it's terribly inefficient to fire off an ajax call to validate each individual field instead of all of them at once. Each request will probably consume at least 5mb of system resources because it requires all of CI to load just to process that one little thing. Personally I don't waste time (my opinion) with javascript-based validation. I just send the entire form via ajax and print any errors that get returned, all in one go. Then if any of my validation rules change, I don't have to remember to update them in 2 places. It's a personal preference based on experience, but I run and maintain several fairly large sites that have a lot of traffic (I consider 10k and growing unique daily visitors "fairly large") where every request counts. Maybe this isn't a concern or applicable to your project.
[eluser]Otemu[/eluser]
Client side validation is good in terms of user experience, for instance a user imputing a invalid email, or entering text when it should be a number, or maybe when entering there repeated password, etc, this way the user gets a faster response, which makes for a better user experience then receiving several errors all at once. A common scenario normally is to have client side validation, then server side validation which can be sent via ajax requests or by a post back.
[eluser]CroNiX[/eluser]
I agree if this were 1990 with dialup internet connections and the connection speed made a difference. The speed difference in today's broadband world is miniscule, but the performance gains aren't. They get the exact same error messages, .02 seconds slower. On my forms I have helper popups for each field telling whats expected up front. So, they get the exact same user-friendly error messages, without all of the extra server requests and resources to process them. Again, it's just my personal preference, and I can code a lot faster without bothering with the duplicating of efforts to get the exact same end result in just about the same amount of time, but consuming a lot less system resources. |
Welcome Guest, Not a member yet? Register Sign In |