Is there a way to check the parameter if its empty or not before submitting?
<form method="GET">
<input name="param1" value="test"/>
<input name="param2" value=""/>
<input type="submit" name="" id="search-submit" class="button" value="Submit">
</form>
If i have a form something like this. the param2 is empty so when I press submit, it look like this
link.com?param1=test¶m2=
so is it possible to attain something like this that when a param is empty. it should not be included. like
link.com?param1=test
since the param2 is empty
Filter before submitting:
you have to check if the param is set with isset() function in php
so :
and mostly the page will give you an error because the $_GET is not set on the first view;
so change the code to::
Using pure javascript, it would be something like - (untested)
Using jQuery, it would be something like - (untested)
Pure javascript method
To answer OP's further question
Always is Better validate Data in the Server Side, the user can disable the javascript and still submit the form. look at this code and try it:
// THE FULL CODE
// myFile.php