i have this input field
  html +='<p style="font-size: 18px; ">Total Bids: <input type="text" class="total_bids" name="total_bids" placeholder="No. of Bids" required></p>';
and the button
html += '<a style="cursor:pointer;" onclick="'+onclick_url_bid_o_matic+'" class="btn-bidoo" id="btn-bidoo">Activate</a>';
i get thie value of the input field via
var totalbids = document.getElementsByName('total_bids')[0].value;
if a user enters a number, it works fine, but if a user does not enter anything and press the activate button, it gives this error,
TypeError: Cannot read property 'style' of null
i want to restrict user to enter something, i already applied required in the input field but that did not work,(i dont know why) any other check with which i can restrict user to enter something?
EDIT:
I get this value in php and i have applied a check there too,
 $total_bids = PSF::requestGetPOST('totalbids');
if(!$total_bids)
        {
            return json_encode(array('error' => 'enter a number'));
        }
but it does not reach till here, as it stops with the null value error
the button leads to this function
bid_o_matic:function(id, uid, e, evt){
            var totalbids = document.getElementsByName('total_bids')[0].value;
            var bidval = document.getElementsByName('bidvalue')[0].value;
            parent_element = $(e).parent().parent();
            if(typeof(evt) != 'undefined'){
                evt.preventDefault();
                evt.stopPropagation();
            }
            if(e.attr('disabled') == 'disabled'){
                return;
            }
            e.button('loading');
            $.post('index.php', {
                page:'__request',
                module:'PSF_auctions',
                action:'make_bid_o_matic',
                id:id,
                uid:uid,
                totalbids: totalbids,
                bidval: bidval
            }, function(d){
                e.button('reset');
                document.getElementById("btn-bidoo").style.visibility = 'hidden';
                document.getElementById("btn-deactivate").style.visibility = 'visible';
                document.getElementById("totalbids").style.visibility = 'hidden';
                document.getElementById("bidvalue").style.visibility = 'hidden';
                if(d.error){
                //        document.getElementById("totalbids").style.visibility = 'visible';
                // document.getElementById("bidvalue").style.visibility = 'visible';
                     $.auctions.alert(d.error);
                    document.getElementById("btn-bidoo").style.visibility = 'visible';
                    document.getElementById("btn-deactivate").style.visibility = 'hidden';
                }
                else
                {
              $(current_price_element).html('<p style="color:#f47321; font-size:16px; font-weight:bold;">Current Price</p><a href="#">'+d.bid_value+'</a>')
                }
            }, 'json');
        },
and the error occurs in this line
 document.getElementById("totalbids").style.visibility = 'hidden';