0

Im not sure if this is possible without using a form. But I would like the browser to render the validation errors. Again, I am doing this programmatically without a form.

i.e. No Form tag, and no submitting. Just straight-up scripting.

Updated

I would like to validate input fields, such as:

 <input value="123" maxlength="5"/>
 <input value="hllo wrld" spellcheck="true"/>
AlvinfromDiaspar
  • 6,611
  • 13
  • 75
  • 140

1 Answers1

0

If you wan't to validate that fields on page load without any additional submit/click event this can be possible solution :

$( document ).ready(function() {

 $("#fieldDiv input").each(function() {

            if(!isNaN(this.value)) {
                alert(this.value + " is a valid number");
            }

        });

});

Idea is to traverse all input fields and perfom validation. You can use custom attributes to know what validation to use.

xsinisa
  • 114
  • 7