Find All the controls in a form using jQuery or javascript

javascript, jquery

Solution

You can add a new property data-charSet in HTML

`<input type="text" id='amt' data-charSet='numeric'>`

add which all controlles you want to add after the "form :"

function submitValidator(){
                   $("form :text, textarea").each(function(){         
                        var NumericOnly = "^[0-9]*$";
                        var svId = $(this).attr('id');
            if($(this).attr('data-charSet') == 'numericonly')
                    {
                         if(!$(this).val().match(NumericOnly)) { 
                            alert("numeric");
                            eval("$('#" + svId +"').focus();")
                            return false;
                            }
                    }
                    });
            }

Problem

I am a starter in jQuery . How to find all the controls in a form using jQuery? I know the code is like this ``` function submitValidator(){ $("form :input").each(function(){ }); ``` I want to access their Id's and need to apply regular expressions Some of the text boxes are numeric remaining will be alphanumeric. Is there any method to sort them to apply regular expressions?

Original source