I have a textbox in one JSP page where the username is entered.Then i have another "Settings" page where there is link for "Change Password" where i have to do the validation username and password(password should not be same as username).But the lightbox for Change password contains only the oldpassword, newpassword and confirmpassword fields..I am wrting a samll function in JS to validate but the value of username is not reached till the js..How to do this??? Please help..
js
function newcheckUsernamAndPassword(field, rules,i,options){
> alert("i am in new method"); var
> newpassword=field.val().toLowerCase(); alert("new pas"
> +newpassword); var username='<%=Session("username")%>'
> alert(username); // var username =
> getValueUsingElementID('username').toLowerCase(); //
> alert("Username"+username); if(newpassword==username){
> return options.allrules.changepassword.alertText; } }
code from Change password
<input type="password" style="width:150px" id="oldpassword" class=" > textBox validate[required,funcCall[checkOldpassword]" > onfocus="jQuery('#authenticateform').validationEngine('attach',{Overflown:false})"/></td> > </tr> > <tr> > <td class="login"><label class="textLable"><msg:message > code="label.newpassword" /></label><span > class="redStar">*</span> </td> > <td class="login"><input type="password" > style="width:150px" id="newpassword" name="newpassword" class="textBox > validate[required,maxSize[30],funcCall[checkOldAndNewPassword],funcCall[newcheckUsernamAndPassword],funcCall[validatePasswordCriteria]]" > > onfocus="jQuery('#authenticateform').validationEngine('attach',{Overflown:false})"/></td> > </tr>
Myadmin Page for Username
<tr> <td class="tblComponent" width="120px" ><label class="tblLabel" for="username"><msg:message code="label.components.userid"/><span class="redStar">*</span></label></td> <td class="borderR tblComponent" width="120px" colspan="3"><input id="username" name="username" type="text" value="" onfocus="jQuery('#adduserform').validationEngine('attach',{Overflown:false})"/></td> </tr>
Please help
According to your question. you can pass a textfield value to javascript by calling a javascript method function. Create a function and call it somewhat like on button. for eg
<input type="button" onclick='abc();' value="Click"/>
now set an id on textfield. and call in javascript function somewhat like.
function abc(){
var a = document.getElementById('textfieldID').val;
}
Sorry but your code is so messed up that i will look it again. but i think if you question is linked up to this(passing textfield from jsp to javascript) then try this.
The best method to pass value of a text field to JavaScript is:
HTML:
<input type="button" onclick='passValue(this);' value="Pass Value"/>
JavaScript:
function passValue(object){
var value = object.value;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.