Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript中的Thymeleaf控件复选框_Java_Javascript_Html_Thymeleaf - Fatal编程技术网

javascript中的Thymeleaf控件复选框

javascript中的Thymeleaf控件复选框,java,javascript,html,thymeleaf,Java,Javascript,Html,Thymeleaf,我有一个带有复选框的表单。提交表单后,我想控制用户是否选中了复选框 以下是我的代码示例: <form action="DoLogin" method="post" id="loginForm"> <h3>Giriş</h3> <label><span>Kullanıcı:</span></label> <input type="text" placeholder="E-posta adres

我有一个带有复选框的表单。提交表单后,我想控制用户是否选中了复选框

以下是我的代码示例:

<form action="DoLogin" method="post" id="loginForm">
    <h3>Giriş</h3>
    <label><span>Kullanıcı:</span></label> <input type="text" placeholder="E-posta adresinizi Giriniz" class="round" name="userName" id="userName" required="true" ></input>
    <label><span>Parola:</span></label> <input type="text" placeholder="Parolanızı Giriniz...." name="password" id="password" required="true" ></input> 
    <label>Giriş Yaparak <span href="#" style="color: red;">Kullanıcı Sözleşmesini</span> Kabul Ediyorum...</label> <input id="userAgreement" type="checkbox" th:checked="${true}"></input>
    <label for="checkbox1" class="round" th:checked="${true}"  id="userAgreement" >Beni Hatırla</label> 
    <a href="#" class="button login round" onclick="login();return false">Giriş</a>
</form>

userAgree==false意味着$(“#用户协议”)是(“:选中”)

function login(){

    var control=true;

    userName =  $('#userName').val(),
    password =  $('#password').val(),
    userAgree = $('#userAgreement').checked`enter code here`

    if(userName.length == 0 ) {

        alert('Lütfen e-posta adresini giriniz.')

        return false;

    }else if( password.length == 0 ){

        alert('Lütfen parolanızı giriniz.')

        return false;

    }else if( userAgree == false ){

        alert('Lütfen kullanıcı sözleşmesini okudum bölümünü işaretleyiniz.')

        return false;
    }


    $('#loginForm').submit();

};
//override the form submit function that will return false when check box is not checked and
// will not submit the form

$("form").submit(function(){
if(!$("#userAgreement").is(":checked"))
{
alert("Please check the agreement");
return false;
}

});
// add above code in your js

function login(){

    var control=true;

    userName =  $('#userName').val(),
    password =  $('#password').val(),
    userAgree = $('#userAgreement').checked`enter code here`

    if(userName.length == 0 ) {

        alert('Lütfen e-posta adresini giriniz.')

        return false;

    }else if( password.length == 0 ){

        alert('Lütfen parolanızı giriniz.')

        return false;

    }else if( userAgree == false ){

        alert('Lütfen kullanıcı sözleşmesini okudum bölümünü işaretleyiniz.')

        return false;
    }


    $('#loginForm').submit();

};