jabz ayuap
asked on
how can I set textbox set to 0 if textbox is empty
my textbox is dynamic, upon creating I set the view value to zero and the user can be able to create then upon updating the textbox, I want to set the value into zero if the textbox was empty by user how can I solve this problem using jquery or condition?
For example
if(textbox == empty)
{
@model = 0
}
else
{
@model
}
For example
if(textbox == empty)
{
@model = 0
}
else
{
@model
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
my other solution here is
$("#table").keyup(function (){
var press = $(this).val();
if($(this).val < 0)
{
$(this).val(0.00)
}
$("#table").keyup(function
var press = $(this).val();
if($(this).val < 0)
{
$(this).val(0.00)
}
ASKER
Thank you eenokami, I like to close this question but I don't know how to declare a close one, Sorry for the inconvenience
ASKER
Gary answer my question already and I really appreciate his help....
var inp = $("#txt").val();
if(jQuery.trim(inp).length
{
$("#txt").val() = 0
}
stackoverflow.com/question