jquery empty input code example

Example 1: how can prevent the empty input in jquery

$('#form').submit(function() {
    if ($.trim($("#email").val()) === "" || $.trim($("#user_name").val()) === "") {
        alert('you did not fill out one of the fields');
        return false;
    }
});

Example 2: clear input field jquery

$('#shares').val('');

Example 3: empty the value of an input in jquery

$('#field').val('');

Example 4: jquery select input with empty value

$('input:text').filter(function() { return $(this).val() == ""; });