jquery validation plugin inline

Go To StackoverFlow.com


I have

<input type="text" class="required" ... />

Is it possible for me to write inside class i required the particular field to number only

I tried

<input type="text" class="number" ... /> and <input type="text" class="{required:true, number:true}" ... />

Is it possible and any idea how? Thanks

2012-04-04 01:37
by cicakman
The class attribute should consist of space separated tokens (see HTML standard - Yuval 2012-04-04 01:41


Try class="required number", see jQuery example here, or run this fiddle:

        <script type="application/javascript">

            // don't really process form
            $("#test-form").submit(function() { return false; });

        <form id="test-form" action="" >
            <input type="text" class="required number" />
            <input type="submit" />

Also, see my comment.

2012-04-04 01:43
by Yuval
not working my frien - cicakman 2012-04-04 01:45
it works for me; see example hereYuval 2012-04-04 01:52
very very sorry my friend, there was an error previously on form, that why its not working.. Thank you - cicakman 2012-04-04 02:04


Maybe you could use a mask for the input text?

See: http://digitalbush.com/projects/masked-input-plugin/

2012-04-04 01:45
by elias