首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用GetOrgChart对输入字段进行验证

使用GetOrgChart对输入字段进行验证
EN

Stack Overflow用户
提问于 2014-11-07 14:28:02
回答 1查看 580关注 0票数 2

如何使用GetOrgChart在输入字段上应用验证?我使用了以下代码。

json_data = $.rails.ajax url:"/organization_units.json“异步: false dataType:"json”

代码语言:javascript
复制
$("#organization").getOrgChart
  gridView: false
  zoomable: true
  printable: true
  editable: true
  color: "neutralgrey"
  primaryColumns: ["Title", "Role","Members"]
  dataSource: json_data.responseJSON.tree_data
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-11-08 17:35:00

我已经为您创建了一个示例,点击“运行代码片段”并尝试用无效的电话号码更新电话。

代码语言:javascript
复制
$("#people").getOrgChart({		
    primaryColumns: ["Name", "Title"],
    dataSource: [
      { id: 1, parentId: null, Name: "Amber McKenzie", Title: "ESL teacher", Phone: "05454545454"},
      { id: 2, parentId: 1, Name: "Ava Field", Title: "Bricklayer",  Phone: "08888888888"},
      { id: 3, parentId: 1, Name: "Evie Johnson", Title: "Nursing aide", Phone: "077777777"}]
});   

$("#people").on("updateEvent", function( event, sender, args ) {  
   if (!/^\d+$/.test(args.data.Phone)){
    event.preventDefault();
    args.returnValue = false;
    alert(args.data.Name + ' cannot be updated because Phone number field is not in correct format!');
  } 
}); 
代码语言:javascript
复制
html, body {margin: 0px; padding: 0px;height: 100%; overflow: hidden; }
#people {width: 100%;height: 100%; } 
代码语言:javascript
复制
<script type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js'></script>

I have created an example for you, hit "Run Code Snippet" and try to update the Phone with invalid phone number.
 



<link rel="stylesheet" type="text/css" href="//www.getorgchart.com/GetOrgChart/getorgchart/getorgchart.css">   
  
    
<script type='text/javascript' src="//www.getorgchart.com/GetOrgChart/getorgchart/getorgchart.js"></script>


<div id="people"></div>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26803441

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档