CodeyMonkey
CodeyMonkey

Reputation: 739

jQuery: Validation, best way to do this?

I have a simple form with basic info e.g.

<label>*Name:</label> [inputbox]
<label>*email:</label> [inputbox]
<label>Company:</label> [inputbox]
<label>Phone:</label> [inputbox]

[submit]

I just want simple validation that turns the input box border red and the text e.g. "*name" red.... I think many validation scripts might be a bit heavy for this simple functionality...

Can anyone reocomend something simple to achieve validation as per above please?

Upvotes: 2

Views: 893

Answers (2)

dknaack
dknaack

Reputation: 60506

Description

One lightweight way ist to use jQuery Validation

Sample

Html

<label for="Company">Company:</label> 
<input id="Company" type="Text" name="Company"/>

jQuery

$("#YourFormId").validate({
    rules: {
        Company: "required",
    },
    messages: {
        Company: "Please enter your Company",
    }
});

More Information

Upvotes: 3

David Laberge
David Laberge

Reputation: 16061

This plugin could help you out :

Site

Demo

Upvotes: 1

Related Questions