我试图在 simplecart 中的项目上添加错误参数时收到警报。当该字段为空或低于 400 或高于 500 时。
一切正常,但当字段为空时不会发出警报。
html:
<input required max="500" min="400" type="number" class="item_width">
JavaScript:
<script>
simpleCart.bind( 'beforeAdd' , function( item ){
if( item.get( 'width' ) < '400'
|| item.get( 'width' ) > '500'
|| item.get( 'width' ) === 'null')
{
alert("Choose between 400 and 500");
return false;
}
});
</script>