fieldLabel : '经度',
name : 'hpLon',
id : 'hpLon',
allowBlank : false,
blankText : '经度不能为空!',
value:hpLon,
vtype:"testLon",
listeners : {
"blur" : function(value) {
transForm(this.id);
}
}
Ext.apply(Ext.form.VTypes, {
testLon: function(v){
//规范的经度表示法ddd°mm′ss.sss″
var lonTest1 = /^((\d|[1-9]\d|1[0-7]\d)[°](\d|[0-5]\d)[′](\d|[0-5]\d)(\.\d{1,6})?[\″]$)|(180[°]0[′]0[\″]$)/;
//有分没秒的表示法ddd°mm.mmm′
var lonTest2 = /^((\d|[1-9]\d|1[0-7]\d)[°](\d|[0-5]\d)(\.\d{1,6})?[′]$)|(180[°]0[′]$)/;
//只有度的表示法 ddd.ddd°
var lonTest3 = /^((\d|[1-9]\d|1[0-7]\d)(\.\d{1,6})?[°]$)|(180[°]$)/;
var s1 = v.split("°");
var state;
if(s1[1] != '' && s1[1] != null){
var s2 = s1[1].split("′");
if(s2[1] != '' && s2[1] != null){
var s3 = s2[1].split("″");
state = lonTest1.test(v);
}else{
state = lonTest2.test(v);
}
}else{
state = lonTest3.test(v);
}
}
if(state){
return true;
}else{
return false;
}
},
testLonText: "经度格式不正确",
testLat: function(v) {
var latTest1 = /^((\d|[1-8]\d)[°](\d|[0-5]\d)[′](\d|[0-5]\d)(\.\d{1,6})?[\″]$)|(90[°]0[′]0[\″]$)/;
var latTest2 = /^((\d|[1-8]\d)[°](\d|[0-5]\d)(\.\d{1,6})?[′]$)|(90[°]0[′]$)/;
var latTest3 = /^((\d|[1-8]\d)(\.\d{1,6})?[°]$)|(90[°]$)/;
var state;
var s1 = v.split("°");
if(s1[1] != '' && s1[1] != null){
var s2 = s1[1].split("′");
if(s2[1] != '' && s2[1] != null){
var s3 = s2[1].split("″");
state = latTest1.test(v);
}else{
state = latTest2.test(v);
}
}else{
state = latTest3.test(v);
}
}
if(state){
return true;
}else{
return false;
}
},
testLatText: "纬度格式不正确"
});
这个是把判断放在vtype中判断的
而transForm 这个是个方法,去转换经纬度,看你到底要以哪种形式显示出来