Welcome Guest, Not a member yet? Register   Sign In
Validation - Custom callback not behaving as expected?
#5

[eluser]ardinotow[/eluser]
[quote author="ianolito" date="1203898898"]I just experienced the same problem. One my fields is not required but I still want to validate it through a custom callback function.

Quote:Validation is not carried out on an empty input unless the “required” switch is used.

Is this a bug that should be reported? Or is this supposed to be normal behavior? I'd like to have someone's input on this.[/quote]

I also have same problem. Callback function will not work on empty field so here is my trick:
1. Set the default value of your field that need to validate to '-' (without qoute)

2. Add this javascript to make sure that '-' will still the default value eventhough a user delete '-':

onFocus="if (this.value=='-'){this.value='';};return false;" onBlur="if (this.value==''){this.value='-';return false;}"

--> copy-paste the javascript to text or textarea identifier. Example:
<textarea name="address" cols="40" rows="4" id="address" onFocus="if (this.value=='-'){this.value='';};return false;" onBlur="if (this.value==''){this.value='-';return false;}">-</textarea>

Now, your callback function should be work!


Messages In This Thread
Validation - Custom callback not behaving as expected? - by El Forum - 02-04-2008, 07:43 PM
Validation - Custom callback not behaving as expected? - by El Forum - 02-04-2008, 08:33 PM
Validation - Custom callback not behaving as expected? - by El Forum - 02-04-2008, 08:44 PM
Validation - Custom callback not behaving as expected? - by El Forum - 02-24-2008, 12:21 PM
Validation - Custom callback not behaving as expected? - by El Forum - 04-01-2008, 09:08 AM
Validation - Custom callback not behaving as expected? - by El Forum - 04-01-2008, 09:33 AM
Validation - Custom callback not behaving as expected? - by El Forum - 04-01-2008, 08:01 PM
Validation - Custom callback not behaving as expected? - by El Forum - 03-21-2010, 07:42 PM
Validation - Custom callback not behaving as expected? - by El Forum - 03-22-2010, 04:58 PM
Validation - Custom callback not behaving as expected? - by El Forum - 03-22-2010, 06:09 PM
Validation - Custom callback not behaving as expected? - by El Forum - 03-22-2010, 11:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB