I have a jquery function which on submit event is generating an url.If one the parameter is not defined, adding to url should be skipped
var category =$("#prod_category").val();
var group =$("#prod_group")
window.location.href = "/page/" +
**//add to url if category is definned**
encodeURI(category) + "/" +
**//add to url if group is definned**
encodeURI(group) + "/" +
You can simply state
if (category). Ifcategoryhas a value with a length greater than zero, this will returntrue.EDIT: When setting the values to
categoryandgroupensure you trim any whitespace that the element may be containing. For example: