當我點擊保存時,我希望我的表單得到驗證,然后彈出視窗應該打開。?但是現在當我點擊保存彈出視窗打開時,關閉彈出視窗后,它顯示驗證。我試過了,但沒有用
<button type="submit" data-toggle="modal" data-target="#saveCerts">Save</button>
模態:
<div id="saveCerts" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div >
<div >
<div >
<h4 >Alert</h4>
<button mat-button type="button" data-dismiss="modal" aria-hidden="true"><i >clear</i></button>
</div>
<div >
<p>Make sure you are providing your finalized label name. You cannot change it in future once you start using it in your projects. </p>
</div>
<div >
<button mat-raised-button type="button" data-dismiss="modal" (click)="uploadCerts()">OK
</button>
</div>
</div>
</div>
</div>
ts:
uploadCerts(){
if (this.labelvalue == null || this.labelvalue == '') {
this.nolabel = true;
return;
}
let format = /[ `!@#$%^&*()_ \-=\[\]{};':"\\|,.<>\/?~]/;
if(format.test(this.labelvalue)){
this.noSpecialChar = true;
return;
}
const ind = this.sslfileDetails.filter((x => x.label == this.labelvalue))
if(ind.length > 0){
this.sharedService.errorAlert("Label already taken")
return
}
if(this.rootdata == undefined && this.certdata == undefined){
if(this.combidata == undefined){
this.sharedService.errorAlert("Please upload either .crt and .key certificates or Combined certificate")
return;
}
}else if(this.rootdata != undefined){
if(this.certdata == undefined){
this.sharedService.errorAlert("Please upload either .crt and .key certificates or Combined certificate")
return;
}
}else if(this.certdata != undefined){
if(this.rootdata == undefined){
this.sharedService.errorAlert("Please upload either .crt and .key certificates or Combined certificate")
return;
}
}
uj5u.com熱心網友回復:
在dovalidation方法內移動驗證。添加驗證完成后將打開模型的按鈕
<button [hidden]="true" id="openModalButton" type="button" data-toggle="modal" data-target="#saveCerts"></button>
<button (click)="dovalidation()" type="button" >Save</button>
并通過dovalidation方法打開模型成功驗證后
document.getElementById("openModalButton").click();
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/312727.html
