Title: validate a textfield just a text!!! Post by: varonica on August 29, 2012, 09:55:07 PM HI admin, i tried to read again and again, but cant find how to extend validtype just a text only!!!!
Code: $.extend($.fn.validatebox.defaults.rules, { Title: Re: validate a textfield just a text!!! Post by: Kevin on August 30, 2012, 11:10:20 AM Hi Varonica
Not sure what you would like to validate, but there are a number of examples in the forums. But here are 3 examples (the temperature validation is similar to number range). $.extend($.fn.validatebox.defaults.rules, { tempRange: { validator: function(value, param){ return (value >= param[0] && value <= param[1]); }, message: 'Temperature must be in the range of {0}°C and {1}°C.' }, numRange: { validator: function(value, param){ return (value >= param[1] && value <= param[2]); }, message: '{0} must be between {1} and {2}.' }, maxLength: { validator: function(value, param){ return value.length <= param[0]; }, message: 'Maximum characters allowed is {0}.' } }); This is the html part; <input id="minTemp" name="minTemp" class="easyui-validatebox tempVal" required="true" validType="tempRange[-50,70]"> <input name="tolerance" size="10" class="easyui-validatebox" validType="numRange['Range',0,5000]"> <textarea name="notes" style="height:80px;width:473px;" class="easyui-validatebox" validType="maxLength[300]"> ></textarea> Title: Re: validate a textfield just a text!!! Post by: varonica on August 31, 2012, 01:09:06 AM Hi Kevin, Thz for reply me. Perhaps u dont understand what i want to achieve clearly. Let get this straight, i have a text box and user can input some value in there but a text is possible to fill in that text box, not number!!! :( plz help me!!
Title: Re: validate a textfield just a text!!! Post by: mzeddd on August 31, 2012, 07:42:35 AM Maybe smth like this?
Code: $.extend($.fn.validatebox.defaults.rules, { http://www.w3schools.com/jsref/jsref_isnan.asp (http://www.w3schools.com/jsref/jsref_isnan.asp) Title: Re: validate a textfield just a text!!! Post by: varonica on August 31, 2012, 06:15:18 PM hi mzeddd, it's not working :( !! plz help me :'(
Title: Re: validate a textfield just a text!!! Post by: mzeddd on September 01, 2012, 11:38:28 AM it is OK for me with following code:
Code: <script type="text/javascript"> Title: Re: validate a textfield just a text!!! Post by: Kevin on September 02, 2012, 10:31:48 PM Hi Varonica, sorry you right, I did not understand what you meant. I guess what you did want to say was "...but cant find how to extend validtype just for text only!!!!". mzeddd solution only tests the first character, so if the user enters "W8", the function passes. I guess not what you want. You can use RegExp to solve this. You can try the following;
Code: justText: { Title: Re: validate a textfield just a text!!! Post by: varonica on September 03, 2012, 12:13:22 AM Thanks, Kevin && mzeddd ^^, u guys help me alot!!
|