Skip to content
Advertisement

Javascript or Jquery validation on textChanged

I need to do the validation for the P.O box on text changed event. If the user types P.O Box in the address text box and also request for expedite shipping by checking a chec box then I need to show the warning message to the user saying that expedite shipping cannot be done to the P.O box address. For this, I have the following code on my aspx page:

JavaScript

if the user types P.O box address in the txtAddress and also checks the chkExpShipping check box then I want the pnlMessage to be visible and show the warning message. If the user changes the txtAddress content from P.O box to regular address then I want the warning to be hidden. In order to achieve this, I wrote this code:

JavaScript

when I start typing in the txtAddress text box, no validation happens. The code does not even go the addChjange javascript function.

any help with this will be appreciated.

Advertisement

Answer

Part of the problem may be that you’re doing a comparison with == when JavaScript has much more predictable results when using the triple ===. Try: if (PostalResult === true)

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement