我正在尝试在角度2表单上进行一些电子邮件验证,但是我无法使其正常工作。
这是我的register.html表格: -
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
try {
JSONObject jsonObjectAD = new JSONObject(s);
jsonArrayAD = jsonObjectAD.getJSONArray("images");
for(int i=0;i<jsonArrayAD.length();i++) {
JSONObject jsonObject7 = jsonArrayAD.getJSONObject(i);
ADUrl = jsonObject7.getString("image");
ADUrl2 = "";
ADUrl3 =ADUrl2.concat(ADUrl);
ADName = jsonObject7.getString("advTitle");
ADId = jsonObject7.getString("advLink");
ADCatName.add(ADName);
ADCatImage.add(ADUrl3);
ADCatId.add(ADId);
Hash_file_maps.put(ADId,ADUrl3);
//Toast.makeText(getApplication(),""+ADId,Toast.LENGTH_SHORT).show();
}
for(String name : Hash_file_maps.keySet()) {
textSliderView = new TextSliderView(MainActivity.this);
textSliderView
// .description(name)
.image(Hash_file_maps.get(name)).setOnSliderClickListener(this);
textSliderView.bundle(new Bundle());
textSliderView.getBundle().putString("extra",name);
sliderLayout.addSlider(textSliderView);
}
sliderLayout.setPresetTransformer(SliderLayout.Transformer.Stack);
sliderLayout.setPresetIndicator(SliderLayout.PresetIndicators.Center_Bottom);
sliderLayout.setCustomAnimation(new DescriptionAnimation());
sliderLayout.setDuration(5000);
sliderLayout.addOnPageChangeListener(this);
} catch (Exception e) {
e.printStackTrace();
}
}
在我的register.component.ts中我有以下内容: -
=IF(C7="f",IF(MIN(IF($C$4:$C$43="m",IF($D$4:$D$43>E7,IF($D$4:$D$43<F7,$G$4:$G$43,""),""),""))>0,MIN(IF($C$4:$C$43="m",IF($D$4:$D$43>E7,IF($D$4:$D$43<F7,$G$4:$G$43,""),""),"")),"no match"),"")
我还需要其他任何东西来进行验证吗?
感谢您的所有帮助和时间。
答案 0 :(得分:2)
HTML5的电子邮件类型默认有效。
<input type="email" class="form-control" name="email" [(ngModel)]="email" placeholder="Email" required minlength="4" >
其他方式是使用ng-pattern
<input ng-pattern = '/^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i' type="email" name="email" class="form-control" ng-model="email" required="" />
<p class="help-block error-block">Enter a valid email address.</p>
答案 1 :(得分:0)
try like this:
Html:
<form id="frmForgetPwd" name="frmForgetPwd" #frm="ngForm">
<div class="form-group">
<label>Registered Email Address</label>
<input type="email" class="form-control" focus
id="emailID" name="emailID" autofocus
#email="ngModel"
ngModel
required>
</div>
<button type="submit (click)="forgotPassword(email.value)">
Submit
</button>
</form>
component:
forgotPassword(emailid: string) {
this.errors = [];
if (emailid == "") {
this.errors.push(new error("invalidemail",Messages.EMAIL_IN_VALID));
return false;
}
let EMAIL_REGEXP = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if (!EMAIL_REGEXP.test(emailid)) {
this.errors.push(new error("invalidemail",Messages.EMAIL_IN_VALID));
return false;
}
}