var inpt = $('#input-box').val();
if (inpt != '') {
$('form').submit();
alert('Voila!'); // (1)
} else {
alert('fill something man'); // (2)
}
I am using this code to automatically submit the form as soon as the page loads.
Here I am unable to use the jquery $(document).ready() function because I m in GreaseMonkey environment.
The form is automatically filled, I used (2) statement for exceptional cases.
I get no alerts! neither from (1) nor from (2).
UPDATE:
<label for="answer">Answer:</label>
<input type="text" name="answer" id="input-box" />
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
Try to put the alert before the submit.
If you want it to auto-submit after a user enter a value then you can do thsi: