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..
我在一个JSP页面中有一个文本框,其中输入了用户名。然后我有另一个“设置”页面,其中有“更改密码”的链接,我必须在那里进行验证用户名和密码(密码不应与用户名相同) 。但是更改密码的灯箱只包含oldpassword,newpassword和confirmmpassword字段。我在JS中使用了一个samll函数进行验证但直到js才达到username的值。怎么做?请帮忙..
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
用户名的Myadmin页面
<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
2 个解决方案
#1
0
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 e.g
根据你的问题。您可以通过调用javascript方法函数将文本字段值传递给javascript。创建一个函数,并在按钮上调用它。例如
<input type="button" onclick='abc();' value="Click"/>
now set an id on textfield. and call in javascript function somewhat like.
现在在textfield上设置id。并调用javascript函数有点像。
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.
对不起,但你的代码太乱了,我会再看一遍。但我想如果你的问题与此相关联(将文本字段从jsp传递到javascript),那么试试这个。
#2
0
The best method to pass value of a text field to JavaScript is:
将文本字段的值传递给JavaScript的最佳方法是:
HTML:
<input type="button" onclick='passValue(this);' value="Pass Value"/>
JavaScript:
function passValue(object){
var value = object.value;
}
#1
0
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 e.g
根据你的问题。您可以通过调用javascript方法函数将文本字段值传递给javascript。创建一个函数,并在按钮上调用它。例如
<input type="button" onclick='abc();' value="Click"/>
now set an id on textfield. and call in javascript function somewhat like.
现在在textfield上设置id。并调用javascript函数有点像。
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.
对不起,但你的代码太乱了,我会再看一遍。但我想如果你的问题与此相关联(将文本字段从jsp传递到javascript),那么试试这个。
#2
0
The best method to pass value of a text field to JavaScript is:
将文本字段的值传递给JavaScript的最佳方法是:
HTML:
<input type="button" onclick='passValue(this);' value="Pass Value"/>
JavaScript:
function passValue(object){
var value = object.value;
}