I’m trying to add the jVal attribute to a textbox that I created in the HTML.
<input id='subJobName' type='text' jval='{valid:function (val) { return validateSubJobName(val); }, message:'Name already exists or is longer than 14 characters.', styleType:'cover'}' />
I would let to add /set the jVal in the javascript instead.
2 reasons –
1st : I will not need to search the HTML to see how each item is validated
2nd : We are using a jqGrid and I would like to add this validation to each text box as its dynamically created.
I thought I would be able to removed the jVal from the HTMl to leave me with plain old text box.
<input id='subJobName' type='text' />
Then in the Doc.Ready function I’d add the jVal to the SubJobName element like so:
$('#subJobName').attr({ jval: { valid: function(val) { return validateSubJobName(val); }, message: 'Nam', styleType: 'cover'} });
This doesn’t work. I’m not sure if I can even do this ? Anyone have any ideas?
Thanks
I have jVal 0.1.4 as a work in progress which adds an init() function for what you’re looking for. Fetch the latest trunk of jVal.js from http://jquery-jval.googlecode.com/svn/trunk/jVal.js.
You can append the jVal and jValKey attributes to fields and then re-initialize the jVal functionality as such: