I have a input field in my html which basically sends the amount to an observable and then redirects to different pages depending on the amount, but I want to make sure that even if a person who doesnt write amount and types in "string values" should still be able to get redirected, but I am not sure how to accomplish that.
HTML CODE
<input id="amount" type="text" data-bind="value : amount" />
<button class="btn button2" type="submit" data-bind=" valueUpdate:'afterkeydown' , click: $root.borrow_first_pageview" ></button>
I do not want to write the type= number in the HTML since I want to know how its checked in the JS.
here is the rest code using knockout.js
self.borrow_first_pageview = function () {
if(self.amount()){
window.location.href = BASEURL + "index.php/moneyexchange/borrow_first_page/" + self.amount();
}else if(typeof self.amount() == 'string'){
window.location.href = BASEURL + "index.php/moneyexchange/borrow_first_page/" + 2500;
}else {
window.location.href = BASEURL + "index.php/moneyexchange/borrow_first_page/" + 2500;
}
};
Is there a way to check if self.amount() is a String and then redirect the user. Need help.