JavaScript Without using a form, how can I check an input field is not empty before running function? post without using form,validation without using form,jquery validation

I have the following code in a SharePoint aspx page ( I got an error that said I cannot use form controls... that is why the form tags are not there):

<div id="formBox">
 Here is a link : <a target='_blank' href="" id=lnk>nothing here yet</a> <br>
<input type='text' id='userInput' />
<input name="codename" type="radio" value="codeA" /> <label for="x">X</label>&nbsp;<input name="codename" type="radio" value="codeB" /><label for="y">Y</label>
<input type='button' onclick='javascript:changeText2()' value='Change Text'/>
 </div>

Here is the function which is supposed to concatenate the information: It works... kind of.. parts of it.

It will add the selected button to the url, and also the input text. However, it is firing before the input is filled out, and then works once you type in the box again.

I tired to add in if statement, to stop the code if the box was not filled out but it didn't work. Here is what I have...

    function changeText2(){
    var userInput = document.getElementById('userInput').value;
  $('#formBox input[type="text"]').on('change', function() {
  var linktest = 'site/info.aspx?' + $('input[name="codename"]:checked', '#formBox').val() + '=' + userInput;
  alert(linktest);
  });

    var lnk = document.getElementById('lnk');
    lnk.href = "http://www.google.com?q=" + userInput;
    lnk.innerHTML = lnk.href;
}

I tried to check the input box like this, but it didn't work:

 if( $('#formBox input[type="text"]').val== "") {    
   alert('no info');
}
Answer:1

I'm trying to find the most graceful way to distinguish between single and double clicks in Bacon.js, but I feel like I'm not completely grasping how this works. The following works for detecting a ...

I'm trying to find the most graceful way to distinguish between single and double clicks in Bacon.js, but I feel like I'm not completely grasping how this works. The following works for detecting a ...

I have a input that have type like this: <input class="emailSend" name="emailSend" type="hidden"> Then I have a multiple select option like this <div class="controls"> <select ...

I have a input that have type like this: <input class="emailSend" name="emailSend" type="hidden"> Then I have a multiple select option like this <div class="controls"> <select ...

  1. fill input type file javascript
  2. fill input type date
  3. fill input type file
  4. auto fill input type file
  5. pre fill input type date
  6. jquery fill input type file
  7. jquery fill input type text
  8. jquery fill input type date
  9. js fill input type file

The cell content selection works successfully for a numeric text box (internally handled as a Kendo NumericTextBox control) but for some reason, it doesn't work with a plain textbox column. Attached ...

The cell content selection works successfully for a numeric text box (internally handled as a Kendo NumericTextBox control) but for some reason, it doesn't work with a plain textbox column. Attached ...

  1. kendo ui grid select row
  2. kendo ui grid select all rows
  3. kendo ui grid select row programmatically
  4. kendo ui grid select row event
  5. kendo ui grid select column
  6. kendo ui grid select all checkbox
  7. kendo ui grid select single row
  8. kendo ui grid select cell programmatically
  9. kendo ui grid select row by index
  10. kendo ui grid select first row by default
  11. kendo ui grid select row on button click
  12. kendo ui grid select row after refresh
  13. kendo ui grid select row angular
  14. kendo ui grid select
  15. kendo ui grid select all
  16. kendo ui grid select event
  17. kendo ui grid select multiple rows
  18. kendo ui grid select row by id
  19. kendo ui grid select first row
  20. kendo ui grid select row checkbox

I want to have two optional parts in my regex - either of them can be found in matching string, and also both of them can at the same time. Both of those optional parts consist of a wildcard (I wrote ...

I want to have two optional parts in my regex - either of them can be found in matching string, and also both of them can at the same time. Both of those optional parts consist of a wildcard (I wrote ...