0

I have been searching for a while now and cant find this.

what I want is to have validation on the "name" field of a form, that if the user enters "a" all the names beginning with "a" will be displayed and so forth when they carry on entering more letter, it will get more defined.

I just want this validation for the "name" field and I already have the 200 "names" that are the most popular, that a user can enter.

any guides on how to easily achieve this?

thanks

1 Answer 1

1

If I'm getting you right you're looking for Ajax auto-complete.

I recommend Jquery AutoComplete: http://jqueryui.com/demos/autocomplete/

Sample of use: (don't forget to include the Jquery UI js file)

<script>
    $(function() {
        var availableNames = [
            "Adam",
            "Andrey",
            "Aharon",
            "Antonio",
            "Kavin"
        ];
        $( "#names" ).autocomplete({
            source: availableNames
        });
    });
    </script>


<div class="ui-widget">
    <label for="names">Write your name:: </label>
    <input id="names">
</div>
Sign up to request clarification or add additional context in comments.

1 Comment

thanks, yes, this is close to what im looking for. but im having trouble understanding that code. where is the source code that I can easily edit and where should I put my 200 names?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.