开发者

Why doesn't this JavaScript evaluation work?

开发者 https://www.devze.com 2023-01-31 14:18 出处:网络
I only want to execure a cerat开发者_StackOverflow中文版in code IF three input fields do not have empty values. So why doesn\'t this code work:

I only want to execure a cerat开发者_StackOverflow中文版in code IF three input fields do not have empty values. So why doesn't this code work:

if($("#field1").val() != "" && $("#field2").val() != "" && $("#field3").val() != "")


Make sure the input fields are named properly? They should have the id attribute for them set.


Do all three inputs have ids matching your selectors? You may also want to check that the type of the values is not undefined like so:

if(typeof($('#field1').val())!='undefined' ... 
0

精彩评论

暂无评论...
验证码 换一张
取 消