Jump to content

Instant Validation from form Fields


suttercain

Recommended Posts

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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.