X-Editable 中的数据清理可能吗?
Data sanitation in X-Editable possible?
我使用的是优秀的 X-editable to enable inline editing of some data on my website. I now want to do some data sanitation (replace commas with dots) before the data gets submitted to the server. In the X-editable docs 但是我找不到任何相关信息。
有人知道我如何在保存数据之前使用 X-Editable 进行数据检查和清理吗?欢迎所有提示!
来自documentation for $(thing).editable({...})
:
Name: validate
Type: function
Default: null
Description: Function for client-side validation. If returns string - means validation not passed and string showed as error. Since 1.5.1 you can modify submitted value by returning object from validate: {newValue: '...'} or {newValue: '...', msg: '...'}
validate: function(value) {
if($.trim(value) == '') {
return 'This field is required';
}
}
我使用的是优秀的 X-editable to enable inline editing of some data on my website. I now want to do some data sanitation (replace commas with dots) before the data gets submitted to the server. In the X-editable docs 但是我找不到任何相关信息。
有人知道我如何在保存数据之前使用 X-Editable 进行数据检查和清理吗?欢迎所有提示!
来自documentation for $(thing).editable({...})
:
Name: validate
Type: function
Default: null
Description: Function for client-side validation. If returns string - means validation not passed and string showed as error. Since 1.5.1 you can modify submitted value by returning object from validate: {newValue: '...'} or {newValue: '...', msg: '...'}
validate: function(value) {
if($.trim(value) == '') {
return 'This field is required';
}
}