I'm using RemoteAttribute
for a particular field on my form. The purpose of it is not important. What is important is that it needs to fire the validation action whenever the field is changed. This is working fine for me except when the field is changed to be blank.
I've Googled this but found no results. Does anybody know if RemoteAttribute
does actually trigger for blank fields and if not, how it can be forced?
Alternatively, can the remote validator be customised/modified to trigger for blank values?
jQuery validation will not run any rules if the value of an element is empty. If you have a minLength = 2 rule but the input field is left empty the rule will not fail. Only if the user enters 1 character it will fail.
The same idea applies to a remote validator. If the value is empty then it does not go to the server.
I don't think there is an option in the plugin to change this behavior. You will need to create a custom async rule to get the behavior you are expecting. This might turn a little tricky. Are you sure there is no other way of doing it? Does it make sense to validate an empty string in the server? Can you add the required rule?
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