There are several ways to check if a input is empty, for example:
$('input:text').val().length == 0
My problem is that i found no solution how to check if the input is empty or blank? How can i check this is there some regex?
Thanks
There are several ways to check if a input is empty, for example:
$('input:text').val().length == 0
My problem is that i found no solution how to check if the input is empty or blank? How can i check this is there some regex?
Thanks
you can use jQuery.trim() to trim your input first:
var value = $('input:text').val();
if ($.trim(value) == '') { /* Empty or blank */ }
You can remove white spaces before checking empty:
if ($("input:text").val().replace(/^\s+|\s+$/g, "").length == 0){