开发者

Livevalidation: don't validate depending on default value

开发者 https://www.devze.com 2023-02-16 07:05 出处:网络
I am trying to validate my form inputs with livevalidation In my html, I have this input field: <input type=\"text\" name=\"size\" size=\"4\" value=\"\" />

I am trying to validate my form inputs with livevalidation

In my html, I have this input field:

<input type="text" name="size" size="4" value="" />

The input above is a optional input on my form and I was wondering if there was a way to skip validation if the value was left empty and once a user types something in there, it would validate.

Also, let say if there was a default value to begin with,

<input type="text" name="size" size="4" value="Put Size Here" />

If the default value is 'Put Size Here', ignore validation and when anything other than 'Put Size Here' is inputted, validate.

I've looked at the presence option fr开发者_如何学JAVAom the link above but it's not what I am looking for exactly. Is it possible to do this with livevalidation or is there another jQuery validation plugin that I could use to achieve this?


Have you tried using the Inclusion? Livevalidation Inclusion, you can try setting the empty value as included.


HTML


<input id="size" name="size" value="Put Size here" />

Javascript


var sizeValidator= new LiveValidation('size');
size.add( Validate.Inclusion, { within: [ 'Put size here' , 'whatever', 'arbitrary' ] } );

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号