I can't get my head around this issue! I have simple jquery validation on button click to validate if the input field is empty.
http://fiddle.jshell.net/fyxP8/3/
I have no idea why the input filed returns with value not empty when it is empty.
Any help is very much appreciated
see this demo: http://fiddle.jshell.net/Tj7Z8/
extra ; on your if statement
Hope it fits the need :)
code
function checkinputs(ticker, btn) {
alert(ticker + "[ " + $(btn).parent().find("input").val() + " ]" + $(btn).parent().find("input").val().length);
var x = false;
if (ticker == 0) {
if ($(btn).parent().find("input").val() != '' ) {
alert($(btn).parent().find("input").attr("name") + "<>" + $(btn).parent().find("input").val());
x = true;
}
}
return x;
}
var progressTicker = 0;
$("button[class$='nextBtn']").click(function() {
var returns = checkinputs(progressTicker, this);
alert(returns);
if (returns == true) {
alert('inside');
}
});
I think you just had a typo in your script in this line
if ($(btn).parent().find("input").val() != '' ); {
The colon is misplaces there... Compare
http://fiddle.jshell.net/fyxP8/10/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With