suttercain Posted May 6, 2009 Share Posted May 6, 2009 Hi everyone, I primarily use the jQuery framework for my ajax and am looking for a tutorial or some guidance on instant form validation. Some sites instantly validate what the user enters into the form field. Exp. "That username already exists." or "Password Weak." I have two semi different form fields I need to apply this to. One would be a MySql validation to check to see if a string exists and the other would be if the user enters over a numeric value another option would appear. Does anyone have a tutorial to point me to? I don't think I'm using the proper keywords in the google search. Thanks. -Shannon Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 6, 2009 Share Posted May 6, 2009 Um... the username will need AJAX. Password strength message doesn't. Look here - http://docs.jquery.com/Ajax Quote Link to comment Share on other sites More sharing options...
xtopolis Posted May 7, 2009 Share Posted May 7, 2009 Regarding password strength: https://security.berkeley.edu/MinStds/Passwords.html Most sites try to adhere to the first set of bullets. The second set takes a bit more implementation. Quote Link to comment Share on other sites More sharing options...
suttercain Posted May 7, 2009 Author Share Posted May 7, 2009 My apologies, I think I was too broad with my questions. I have two needs Example 1 Let us say I have a numeric form field. If the user enters a value over 25, a div will display information instantly without page refresh. If they enter 24 or lower, no additional div will display. Example 2 Another numeric form field which collects a 17 digit value. Once the user has entered 17 digits an ajax call is made to MySql to see if this 17 digit number entered actually exists in the database. If it does, the user is good to go. If not, they are told that number does not exists. This may work for Example 2: http://jqueryfordesigners.com/demo/ajax-validation.php But that link only shows how to do it with JSON and I need it to tie into MySql instead. Thanks again for any and all help. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 7, 2009 Share Posted May 7, 2009 1. JavaScript + onkeyup 2. AJAX It would help if you can be more specific in what kind of help you need. Quote Link to comment Share on other sites More sharing options...
suttercain Posted May 7, 2009 Author Share Posted May 7, 2009 It would help if you can be more specific in what kind of help you need. As far as Example 2, the link I posted is a pretty good example of what I want to do. In that example they use jQuery to make the ajax call and I'm getting it close. However, as I stated in the previous post, the example uses JSON but I need it to instead grab the information from MySql. Original Code From Example: <?php $taken_usernames = array( 'remy', 'julie', 'andrew', 'andy', 'simon', 'chris', 'nick' ); ?> So that code will basically display that the "information already exists" if the user types in julie, remy, etc. Now when I try to get the database instead I use the following code which only works for the first record because it's not collecting it into a proper array. <?php $sql = mysql_query("SELECT * FROM users"); $taken_usernames = mysql_fetch_assoc($sql); ?> Thanks again. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 7, 2009 Share Posted May 7, 2009 What do you mean it's not collecting it into a proper array? It's an array. o.O What's your definition of a "proper" array? Use a while loop to get more than 1 result. Quote Link to comment Share on other sites More sharing options...
Mchl Posted May 7, 2009 Share Posted May 7, 2009 Use json_encode to transform an array into a JSON Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 7, 2009 Share Posted May 7, 2009 Use json_encode to transform an array into a JSON Just to tack on a note - json_encode() is only available in PHP version 5. Quote Link to comment Share on other sites More sharing options...
Mchl Posted May 7, 2009 Share Posted May 7, 2009 Which is the only version currently supported by me. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.