www.webdeveloper.com
Results 1 to 12 of 12

Thread: function call is not working

Hybrid View

  1. #1
    Join Date
    Jul 2014
    Posts
    7

    function call is not working

    I have the following code (which is actually embedded in PL/SQL)

    <input style="width=120" type="button" name="p_arg_values" value="Reset Password" onclick="javascript:ValPwd()">

    It used to work in IE8, but it is not working in IE11.

    Any help is appreciated.

    Thanks.

  2. #2
    Join Date
    Jul 2014
    Posts
    7
    The function call is not working. Onclick event works fine, when I tried with an alert.

  3. #3
    Join Date
    Nov 2010
    Posts
    1,086
    is it working in other browsers? what does the error console say?

  4. #4
    Join Date
    Jul 2014
    Posts
    7
    error console doesn't show anything. button click does nothing.

  5. #5
    Join Date
    May 2014
    Posts
    1,020
    see this?

    style="width=120"

    Style should be css. width=120 is invalid CSS. Did you mean:

    style="width:120px;"

    I hope not, PX widths are an inaccessible mess.

    onclick="javascript:ValPwd()"

    onclick IS javascript, you don't say javascript: inside it. "javascript:" is for when you put scripting in a HREF.

    NOT that any script worth using is going to be using the onevent attributes in the markup in the first place!

    For now, I SUSPECT what you want is this:

    Code:
    <input style="width:120px" type="button" name="p_arg_values" value="Reset Password" onclick="ValPwd();" />
    Though given that's a scripting only element it doesn't even belong in the HTML in the first place... nor really does STYLE when it's something simple like a width -- that belongs in your external stylesheet.

    or did you mean to use something like size="16" instead?

    Bottom line -- that HTML is broken gibberish, it shouldn't work in ANY browser.
    Last edited by deathshadow; 07-29-2014 at 02:31 PM.
    Java is to JavaScript as Ham is to Hamburger.

  6. #6
    Join Date
    Jul 2014
    Posts
    7
    Quote Originally Posted by deathshadow View Post
    see this?

    style="width=120"

    Style should be css. width=120 is invalid CSS. Did you mean:

    style="width:120px;"

    I hope not, PX widths are an inaccessible mess.

    onclick="javascript:ValPwd()"

    onclick IS javascript, you don't say javascript: inside it. "javascript:" is for when you put scripting in a HREF.

    NOT that any script worth using is going to be using the onevent attributes in the markup in the first place!

    For now, I SUSPECT what you want is this:

    Code:
    <input style="width:120px" type="button" name="p_arg_values" value="Reset Password" onclick="ValPwd();" />
    Though given that's a scripting only element it doesn't even belong in the HTML in the first place... nor really does STYLE when it's something simple like a width -- that belongs in your external stylesheet.

    or did you mean to use something like size="16" instead?

    Bottom line -- that HTML is broken gibberish, it shouldn't work in ANY browser.
    sorry, didn't help.

  7. #7
    Join Date
    May 2014
    Posts
    1,020
    Does ValPwd() even exist in your scripting? Is it in an external script and if so are you sure it's being loaded?

    Could we see the actual page live somewhere? If your markup was that broken, dimes to dollars you've got all sorts of things wrong any one of which could be tanking script execution. One buggy script, kiss off ALL your scripting working.

    Is the script written using legacy IE proprietary code that IE11 doesn't support now that they've joined the rest of the world? If so is your script also broken in FF/Chrome/Safari/Opera/iCab/Blazer/Konqueror/anything that's not IE8/earlier?

    Really you're not showing us enough to help you.
    Java is to JavaScript as Ham is to Hamburger.

  8. #8
    Join Date
    Jul 2014
    Posts
    7
    Quote Originally Posted by deathshadow View Post
    Does ValPwd() even exist in your scripting? Is it in an external script and if so are you sure it's being loaded?

    Could we see the actual page live somewhere? If your markup was that broken, dimes to dollars you've got all sorts of things wrong any one of which could be tanking script execution. One buggy script, kiss off ALL your scripting working.

    Is the script written using legacy IE proprietary code that IE11 doesn't support now that they've joined the rest of the world? If so is your script also broken in FF/Chrome/Safari/Opera/iCab/Blazer/Konqueror/anything that's not IE8/earlier?

    Really you're not showing us enough to help you.

    The function does exit. As I mentioned earlier, it works fine in IE8. In IE11, when I click the button, the control is not going to the ValPwd function, and it doesn't give any error. It appears like nothing is happening on clicking the button. To check the onclick functionality, I put an alert message instead of function call and the message pops up fine. didn't want to post the whole code here. It has pure PL/SQL code and embedded javascript.

    Thanks.

  9. #9
    Join Date
    May 2014
    Posts
    1,020
    Well, without seeing the code for that function, we really can't help you.

    Though I'm wondering why you'd have pl/sql code mixed with JS... sounds... sloppy.
    Java is to JavaScript as Ham is to Hamburger.

  10. #10
    Join Date
    Jul 2014
    Posts
    7
    That is because it is written for Oracle Portal.

    Here is the Code..

    <HTML>
    <HEAD>
    <TITLE>Password Reset Form</TITLE>
    <meta http-equiv="X-UA-Compatible" content="IE-edge" />
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="-1">
    <script language="JavaScript">
    void function ValPwd(Void)
    {
    var a
    var b
    var c
    var d
    var e
    var f
    var x
    var y
    var g
    var h
    // get contents of inputboxes
    a=document.getElementById("usernameinput");
    b=a.value;
    c=document.getElementById("dobinput");
    d=c.value;
    e=document.getElementById("ssninput");
    f=e.value;
    x=document.getElementById("passwordinput");
    y=x.value;
    g=document.getElementById("passwordinput2");
    h=g.value;

    if (b=="") {
    alert("Username is required. Please enter the username.");
    a.focus();
    a.select();
    return;
    }
    if (d=="") {
    alert("Date of Birth is required. Please enter the date of birth.");
    c.focus();
    c.select();
    return;
    }
    if (!isDate(d,"MM/dd/yyyy")) {
    alert("Date entered is not valid. Please enter a valid date in mm/dd/yyyy format.");
    c.focus();
    c.select();
    return;
    }
    if (f=="") {
    alert("Last 4 digits of SSN is required. Please enter the last 4 digits of SSN.");
    e.focus();
    e.select();
    return;
    }
    if ((!_isInteger(f)) || (f.length != 4)) {
    alert("Last 4 digits of SSN field must contain 4 numeric digits. Please re-enter.");
    e.focus();
    e.select();
    return;
    }
    if (y=="") {
    alert("New Password is required. Please enter the password.");
    x.focus();
    x.select();
    return;
    }
    if (validPassword(y))
    {
    if (y!=h) {
    alert("Passwords do not match. Please enter the password again.");
    g.focus();
    g.select();
    return;
    }
    else
    {
    PageParams="p_arg_names=p_user_name&p_arg_values=" + b + "&p_arg_names=p_dob&p_arg_values=" + d +"&p_arg_names=p_ssn&p_arg_values=" + f +"&p_arg_names=p_new_pass&p_arg_values=" + y
    window.open("/portal/pls/portal/portal_cust.dyn_por_fgt_pwd_reset.show?" + PageParams, "_self");
    }
    }
    else
    {
    alert("Invlid Password.");
    x.focus();
    x.select();
    }
    return;
    }
    function validPassword(sPassword)
    {
    var s
    var s1
    var x
    var len
    var ssPassword
    var pwd1
    var a
    var b
    var cnt=0;
    var filterU=/^[A-Z]{1,}$/;
    var filterA=/^[a-z]{1,}$/;
    var filterN=/^[0-9]{1,}$/;
    var filterS=/^[a-zA-Z]{1,}$/;


    // Password must be at least 8 characters
    if (sPassword.length < 8)
    {
    return false;
    }

    // Password must contain no special charaters or symbols
    for (x=0; x<sPassword.length; x++)
    {
    s = sPassword.substring(x, x+1)
    if ((!filterS.test(s)) && (!filterN.test(s)))
    {
    // There are special characters
    return false;
    }
    }

    // Password must not contain repeating charaters
    len = sPassword.length - 1
    for (x=0; x<len; x++)
    {
    s = sPassword.charAt(x)
    s1 = sPassword.charAt(x+1)
    if (s.toUpperCase() == s1.toUpperCase())
    {
    // There are repeating characters
    return false;
    }
    }

    if (sPassword.length > 8)
    {
    ssPassword = sPassword.substring(0,8);
    }
    else
    {
    ssPassword = sPassword;
    }

    // Password must contain at least 1 number
    for (x=0; x<ssPassword.length; x++)
    {
    s = ssPassword.substring(x, x+1)
    if (filterN.test(s))
    {
    cnt++;
    break;
    }
    }

    if (cnt == 0)
    {
    return false;
    }

    // Password must contain at least 1 upper case
    cnt = 0;
    for (x=0; x<ssPassword.length; x++)
    {
    s = ssPassword.substring(x, x+1)
    if (filterU.test(s))
    {
    cnt++;
    break;
    }
    }

    if (cnt == 0)
    {
    return false;
    }

    // Password must not contain username or reverse shift of username
    a=document.getElementById("usernameinput");
    b=a.value;
    var uPassword=sPassword.toUpperCase();
    var ub=b.toUpperCase();
    var revuser=b.split('').reverse().join('');
    var urevuser=revuser.toUpperCase();
    if (uPassword.indexOf(ub)!= -1)
    {
    return false;
    }
    if (uPassword.indexOf(urevuser)!= -1)
    {
    return false;
    }

    // Password must contain at least 1 lower case
    for (x=0; x<ssPassword.length; x++)
    {
    s = ssPassword.substring(x, x+1)
    if (filterA.test(s))
    {
    // found lower case
    return true;
    }
    }

    // last one failed
    return false;
    }

    function disableEnterKey(e)
    {
    // Get event keycode
    var key = window.event.keyCode;

    if (key == 13)
    {
    // cancel the enter key
    return false;
    }
    else
    {
    return true;
    }
    }
    </script>
    </HEAD>
    <BODY>
    <form name="myform" toolbar=no>
    <table border="0" cellpadding="0" cellspacing="0" style="position:absolute; left:-3; top:-3" bordercolor="#C0C0C0" width="353" height="322" style="position: absolute; left: 0; top: 0">

    <tr>
    <td width="353" height="47" align="center" colspan="2" bgcolor="#C0C0C0"
    valign="bottom">
    <font size="4">Password Reset Form</font>
    </td>
    </tr>
    <tr>
    <td width="353" height="37" align="center" colspan="2"
    <input type="hidden" name="p_arg_names" value="p_user_name" size="20">User Name:
    <input id="usernameinput" type="text" name="p_arg_values" size="18" onKeyPress="return disableEnterKey(event)">


    </td>
    </tr>
    <tr>
    <td width="353" height="37" align="center" colspan="2"
    <input type="hidden" name="p_arg_names" value="p_dob" size="20">Date of Birth (mm/dd/yyyy):
    <input id="dobinput" type="text" name="p_arg_values" size="18" onKeyPress="return disableEnterKey(event)">
    </td>
    </tr>
    <tr>
    <td width="353" height="37" align="center" colspan="2"
    <input type="hidden" name="p_arg_names" value="p_ssn" size="20">Last 4 digits of SSN:
    <input id="ssninput" type="password" name="p_arg_values" size="20" onKeyPress="return disableEnterKey(event)">
    </td>
    </tr>
    <tr>
    <td width="353" height="37" align="center" colspan="2"
    <input type="hidden" name="p_arg_names" value="p_new_pass" size="20">New Password:

    <input id="passwordinput" type="password" name="p_arg_values" size="20" onKeyPress="return disableEnterKey(event)">
    </td>
    </tr>
    <tr>
    <td width="353" height="37" align="center" colspan="2"
    <input type="hidden" name="p_arg_names" value="p_new_pass2" size="20">Re-enter Password:
    <input id="passwordinput2" type="password" name="p_arg_values" size="20" onKeyPress="return disableEnterKey(event)">
    </td>
    </tr>
    <tr>
    <td width="353" height="37" align="center" colspan="2"
    <br><i>(Password must be at least 8 characters,<br>contain at least 1 number, one upper case and <br> one lower case letter, no repeating characters,<br>
    symbols, first/last name or username and <br> cannot re-use the last 8 passwords.)</i>
    </td>
    </tr>
    <tr>
    <td width="353" height="67" align="center" colspan="2">
    <input type="hidden" name="p_arg_names" value="p_submit" size="20">
    <input style="width:120px" type="button" name="p_arg_values" value="Reset Password" onclick="ValPwd();" />
    <input style="width=120" type="button" onClick="javascript:window.close()" value="Cancel">
    </td>
    </tr>
    </table>
    </form>
    </BODY>
    <HEAD>
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="-1">
    </HEAD>
    </HTML>

  11. #11
    Join Date
    May 2014
    Posts
    1,020
    1) Why do you have a second invalid HEAD after BODY?

    2) What makes your form tablular data?

    3) where are your LABELs and FIELDSETs?

    4) If you have multiple VAR in a row, you don't need to say VAR reach and every time.

    5) If you have multiple checks doing the same thing, combine them.

    6) your 'reset password' isnt' a form reset, it's a submit... so make it a submit and trap onsubmit instead of onclick on the input.

    7) No doctype, IE is in "quirks mode"

    8) If you have to use the X-UA compatible garbage, you've done something wrong.

    9) You're using tags and attributes like BGCOLOR, BORDERCOLOR and FONT that have NO business on any website written after 1997. Even your use of the LANGUAGE attribute on SCRIPT is a decade and a half out of date... Much less attributes that never actually existed like TOOLBAR.

    10) variable names that actually mean something might be handy.

    11) Avoid making excess variables for nothing.

    12) you don't even have an action for the form, so it doesn't work without JS; which there's no reason to do since you HAVE to re-check values server-side anyways otherwise any script-kiddy can instahack you... you are checking those values again server-side and re-issuing the form on error, right?

    13) what the devil are you disabling the enter key for?!?

    14) You seem to be trying to use window.open to do the submit, that's LOVELY what with that being blocked in many browsers as a security risk or just plain annoying to users. When you hit your send, does modern IE pop up a little warning box at the bottom saying "window blocked"? It would for me in Opera and FF...

    15) much less sending the login as GET... Security, what's that?

    16) You seem to be copying values with scripting to hidden inputs for christmas knows what reason... and using the same name on multiple inputs which is outright gibberish.

    17) this also seems to be run inside a scripted window.open? JS for nothing just pissing away your accessibility -- meaning the entire site construction method is "questionable" and may need a good toss.

    Really your scripting is ten times the size it should be, you're hooking the wrong element for testing a submit, and your markup is a oddball mix of outdated style and broken methdologies -- that it works in ANY browser is a bit surprising. Even how you're interfacing to your server-side code is just the wrong way of doing things... Just how long have you been on this code given that it should have stopped working over a decade ago, NOT that it was EVER good practice or the proper way of doing things...

    It's really a poster child for the unwritten rule or JavaScript -- "if you can't make the page work without scripting FIRST, you have no business adding scripting to it."

    Sorry if that seems harsh, but that's the truth of the matter on this one. I would HIGHLY recommend tossing that entire mess and at the very least drag it kicking and screaming up to 1998 style practices. I really have to wonder what the devil whoever wrote that was actually thinking...

    This would be an example of dragging that markup into what it should have been as of 1998...

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html
    	xmlns="http://www.w3.org/1999/xhtml"
    	lang="en"
    	xml:lang="en"
    ><head>
    
    <meta
    	http-equiv="Content-Type"
    	content="text/html; charset=utf-8"
    />
    
    <meta
    	http-equiv="Content-Language"
    	content="en"
    />
    
    <meta
    	name="viewport"
    	content="width=device-width; height=device-height; initial-scale=1.0"
    />
    
    <link
    	type="text/css"
    	rel="stylesheet"
    	href="screen.css"
    	media="screen,projection,tv"
    />
    
    <title>
    	Password Reset
    </title>
    
    </head><body>
    
    <form
    	id="passwordReset"
    	action="/portal/pls/portal/portal_cust.dyn_por_fgt_pwd_reset.show"
    	method="post"
    >
    
    	<h1>Password Reset</h1>
    	
    	<fieldset>
    	
    		<label for="prUsername">User Name:</label>
    		<input
    			type="text"
    			id="prUsername"
    			name="p_user_name"
    			size="20"
    		/>
    		<br />
    		 
    		<label for="prDoB">Date of Birth (mm/dd/yyyy):</label>
    		<input
    			type="text"
    			id="prDoB"
    			name="p_dob"
    			size="10"
    			maxLength="10"
    		/>
    		<br />
    		
    		<label for="prSSN">Last 4 digits of SSN:</label>
    		<input
    			type="text"
    			id="prSSN"
    			name="p_ssn"
    			size="4"
    			maxlength="4"
    		/>
    		<br />
    		
    		<label for="prPassword">New Password:</label>
    		<input
    			type="password"
    			id="prPassword"
    			name="p_new_pass"
    			size="20"
    		/>
    		<br />
    		
    		<label for="prPasswordVerify">Re-Enter Password:</label>
    		<input
    			type="password"
    			id="prPasswordVerify"
    			name="p_new_pass2"
    			size="20"
    		/>
    		<p class="information">
    			Password must be at least 8 characters, contain at least 1 number, one upper case and one lower case letter, no repeating characters, symbols, first/last name or username and <br> cannot re-use the last 8 passwords.
    		</p>
    		
    	</fieldset>
    	
    	<div class="submitsAndHiddens">
    		<input type="submit" value="Reset Password" />
    		<input type="button" id="prCancel" value="Cancel" />
    	</div>
    	
    </form>
    
    <script type="text/javascript" src="passwordCheck.js"></script>
    
    </body></html>
    I'll see if I can port the scripting into something less of a wreck for you too -- everything else you were doing there belongs in the CSS, not the markup.

    But even with those changes, good luck interfacing it to your back-end code because, well... if the front end is this jacked up...
    Java is to JavaScript as Ham is to Hamburger.

  12. #12
    Join Date
    Jul 2014
    Posts
    7
    Thanks for the reply. Obviously it was not written by a JS expert.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles