Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

While using struts html tags, How do I get the value of a textbox using its property attribute? Is there any other way to get the value?

    function validate(){
    var username = document.getElementByProperty("userName").value;
    var password = document.getElementByProperty("passWord").value;
    if((username == null ||username =='') || (password == null||password=='')){
     x=document.getElementById("error");
     x.innerHTML = "Username or Password Cannot Be Blank";
    else{
       document.getElementById("loginform").submit();
    }


    <form id="loginform" action="login.do" method="post">
    UserName:<html:text property="userName"></html:text>
    PassWord:<html:password property="passWord"></html:password>
    <html:button onclick="validate()"></html:button>
    </form>

the above code is not working and I am unable to get the values in textbox for validation... Please help me out in this issue...

like image 667
Rajaah Avatar asked Jan 28 '26 20:01

Rajaah


1 Answers

function validate(){
    var username = document.getElementById("userName").value;
    var password = document.getElementById("passWord").value;
}


<form id="loginform" action="login.do" method="post">
    UserName:<html:text property="userName" styleId="userName"></html:text>
    PassWord:<html:password property="passWord" styleId="passWord"></html:password>
    <html:button onclick="validate()"></html:button>
</form>
like image 101
RaceBase Avatar answered Jan 31 '26 09:01

RaceBase



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!