-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnw.js
1 lines (1 loc) · 2.65 KB
/
nw.js
1
/*! nwJS | (c) Muhammad Fauzan | github.com/fauzan121002/nwjs/license.md */ class Nw{constructor(){this.inputCount=0,this.totalInputCount=0}start(){let t=document.querySelectorAll("form[validate] input[type=text],input[type=checkbox],textarea,input[type=password],input[type=email],input[type=file]");for(let u of t)this.inputCount=this.inputCount+1,this.totalInputCount=this.totalInputCount+1;document.querySelectorAll("form[validate]").forEach(t=>{let u=t;t.addEventListener("submit",t=>{t.preventDefault(),document.querySelectorAll("form[validate] input[type=text]").forEach(t=>{""===t.value?(this.inputCount=this.inputCount+1,(this.inputCount>this.totalInputCount||this.inputCount<this.totalInputCount)&&(this.inputCount=this.totalInputCount),t.style.boxShadow="0px 0px 3px red"):(t.style.boxShadow="",this.inputCount=this.inputCount-1,0==this.inputCount&&u.submit())}),document.querySelectorAll("form[validate] textarea").forEach(t=>{""==t.value?(this.inputCount=this.inputCount+1,(this.inputCount>this.totalInputCount||this.inputCount<this.totalInputCount)&&(this.inputCount=this.totalInputCount),t.style.boxShadow="0px 0px 3px red"):(t.style.boxShadow="",this.inputCount=this.inputCount-1,0==this.inputCount&&u.submit())}),document.querySelectorAll("form[validate] input[type=checkbox]").forEach(t=>{0==t.checked?(this.inputCount=this.inputCount+1,(this.inputCount>this.totalInputCount||this.inputCount<this.totalInputCount)&&(this.inputCount=this.totalInputCount),t.style.boxShadow="0px 0px 3px red"):(t.style.boxShadow="",this.inputCount=this.inputCount-1,0==this.inputCount&&u.submit())}),document.querySelectorAll("form[validate] input[type=password]").forEach(t=>{""==t.value?(this.inputCount=this.inputCount+1,(this.inputCount>this.totalInputCount||this.inputCount<this.totalInputCount)&&(this.inputCount=this.totalInputCount),t.style.boxShadow="0px 0px 3px red"):(t.style.boxShadow="",this.inputCount=this.inputCount-1,0==this.inputCount&&u.submit())}),document.querySelectorAll("form[validate] input[type=email]").forEach(t=>{""==t.value?(this.inputCount=this.inputCount+1,(this.inputCount>this.totalInputCount||this.inputCount<this.totalInputCount)&&(this.inputCount=this.totalInputCount),t.style.boxShadow="0px 0px 3px red"):(t.style.boxShadow="",this.inputCount=this.inputCount-1,0==this.inputCount&&u.submit())}),document.querySelectorAll("form[validate] input[type=file]").forEach(t=>{0==t.files.length?(this.inputCount=this.inputCount+1,(this.inputCount>this.totalInputCount||this.inputCount<this.totalInputCount)&&(this.inputCount=this.totalInputCount),t.style.color="red"):(t.style.color="black",this.inputCount=this.inputCount-1,0==this.inputCount&&u.submit())})})})}}(new Nw).start();