javascript - Contact the Field button when there are two buttons -
i have problem. want build home page 2 fields: username , password, , click ok button. under button, there button clicking on sign how associate fields of existing user button , not button of registration?
<fieldset> <legend>login details</legend> <div class="form-group "> <label for="username">user name:</label> <input type="text" name="username" class="form-control requiredfield signin" id="username"> </div> <div class="form-group"> <label for="password">password:</label> <input type="password" name="password" class="form-control requiredfield signin" id="password"> </div> <div class="form-group"> <button type="submit" class="btn btn-default butt" name="submitbutton" value="signin">ok</button> </div> </fieldset> <fieldset> <legend>sign in</legend> <div class="form-group"> <label for="password">account number:</label> <input type="password" name="account" class="form-control requiredfield regi" id="account"> </div> <div class="form-group"> <button type="submit" class="btn btn-default butt" name="submitbutton" value="regi">registration</button> </div>
$(document).ready(function(){
//function registration_submit(){
$("form").submit(function(){ $(".error").remove(); var haserror = false; if (request.form("submitbutton":("signin"){ $(this).each(function(){ if(jquery.trim($(this).val()) == ''){ haserror = true; var labeltext = $(this).prev("label").text(); var n = labeltext.lastindexof(":"); labeltext = labeltext.slice(0,n); $(this).parent().append('<span class="error"> must fill ' + labeltext + '</span>'); console.log('the value of haserror is' + haserror); } }); } else{ $(".regi").each(function(){ if(jquery.trim($(this).val()) == ''){ haserror = true; $(this).parent().append('<span class="error">you must fill account number</span>'); console.log('the value of haserror is' + haserror); } }); } if(!haserror){ $(this).submit(); } return false; });
});
Comments
Post a Comment