Disable Validator but Validator Callout still shows and causes validation

I'm trying to validate that a certain increment of a product was entered in the product qty textbox that is in a repeater. The problem is that the increment is different for every product, so I need that as a variable for each call to validate it (which I don't think you can do with a custom validator), and I need it client side with a ValidatorCalloutExtender. The best solution i have come up with is to trigger a RegEx validator that will evaluate false via my own javascript (another validator takes care of making sure its a valid number). The problem is that with the ValidatorCalloutExtender, when I disable the validator it still marks it as invalid (the textbox flashes white then turns yellow again (meaning its invalid), even though I placed JavaScript alerts and I know the validator is getting disabled. Anyone have any ideas as to whats going on here? Here is the code. Thanks! PS: Everything works fine w/out the validatorCalloutExtender, but I really need the Callout Extender! The validators: When Databinding the product: Dim productQtyTxt As TextBox productQtyTxt = CType(e.Item.FindControl("ProductQtyTxt"), TextBox) Dim incrementValidator As RegularExpressionValidator incrementValidator = CType(e.Item.FindControl("ProductIncrementValidator"), RegularExpressionValidator) incrementValidator.ErrorMessage = "Please enter an increment of " & product.OrderIncrement.ToString() ' Add item qty increment check productQtyTxt.Attributes.Add("onChange", "javascript:checkIncrement('" _ & productQtyTxt.ClientID & "', " _ & product.OrderIncrement & ", '" _ & incrementValidator.ClientID & "')") The Javascript: function checkIncrement(textboxID, incrementQty, validatorID) { var textbox = $get(textboxID); var incrementValidator = $get(validatorID); var qtyEntered = textbox.value; if ((qtyEntered % incrementQty) != 0) { ValidatorEnable(incrementValidator, true); alert("not valid"); return; } else { ValidatorEnable(incrementValidator, false); alert("valid"); return; } }
I set the textbox's cssclass to blank in the javascript function and hid the callout, so now that works but when focus is set on the box it calls the validation and tries to validate against my ^triggerthisvalidation$ expression for the RegEx validator. How can I make it not trigger validation on focus?

以上就是Disable Validator but Validator Callout still shows and causes validation的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏