javascript/jquery input validation -


I have a form where a user can add more input boxes to the click button. Users can have as many input boxes as they want.

I am not planning to add a button to remove the field.

The default number of the input box is 2. To add 3 more, now the total is 5. For verification, I would like to check that the input box is empty or if all these spaces are in the input: "" how many places are there until there is nothing in its place. I can check for the empty input by checking the length, But how can I check for later? Is there a regular expression for a continuous number of spaces? Thanks!

PS: I am using jQuery with jQuery Mobile

You can check if an input field is empty by checking your .value.length , as you already know, to check that it has only spaces, then try: (this Assuming that the input is stored in a variable named input )

  if (! Input.value.trim (). Length) // oh noes! It is full of empty or white space!  

.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -