Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Newbie JavaScript Help

Newbie JavaScript Help

Scheduled Pinned Locked Moved Web Development
helpcsharpquestionjavascriptasp-net
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gmhanna
    wrote on last edited by
    #1

    Hi, I am trying to write a script that will take an input field value from a ASP.NET form and determine if its magnetic data from a magstrip on a credit card. The application is written in C# and uses Server Validation controls to validate the data. The controls need to run server side because when the SUBMIT button is pushed the server needs to validate the data. I do not want to send the data when the Credit Card Number field looses focus to the server, it is disruptive to the user but I need to determine if the card was swipped and if so pull off the Card Number, Card Holder's Name and the Expiration Date and populate the fields. Since I'm new to JavaScript, I figured I would write something simple and hook it to my code for OnTextChange. The problem is I'm receiving the following error: Compiler Error Message: CS0117: 'ASP.WebForm1_aspx' does not contain a definition for 'isScanned' I put my JavaScript in the head section as follows: Merchant Charge Plus / 2004 Web - Authorization Screen function isScanned( ) { var index = 0; CardNo = document.Form1.efCardNo.value; if (CardNo.subString(0, 2) == "%b" || CardNo.subString(0, 2) == "%B" || CardNo.subString(0, 2) == "%a" || CardNo.subString(0, 2) == "%A") { window.alert("Card was scanned"); } return; } and the call for the routine is: asp:TextBox id="efCardNo" style="Z-INDEX: 112; LEFT: 152px; POSITION: absolute; TOP: 67px" tabIndex="3" OnTextChanged="isScanned" runat="server" ToolTip="Enter the Card Holder's name as it appears on the card" Width="193" I don't see what I did wrong, I see the function. Is it because of the runat="server" and it thinks the function is on the server? If so, how do I have a client side routine and a server side? Thanks for your help, Glenn

    C 1 Reply Last reply
    0
    • G gmhanna

      Hi, I am trying to write a script that will take an input field value from a ASP.NET form and determine if its magnetic data from a magstrip on a credit card. The application is written in C# and uses Server Validation controls to validate the data. The controls need to run server side because when the SUBMIT button is pushed the server needs to validate the data. I do not want to send the data when the Credit Card Number field looses focus to the server, it is disruptive to the user but I need to determine if the card was swipped and if so pull off the Card Number, Card Holder's Name and the Expiration Date and populate the fields. Since I'm new to JavaScript, I figured I would write something simple and hook it to my code for OnTextChange. The problem is I'm receiving the following error: Compiler Error Message: CS0117: 'ASP.WebForm1_aspx' does not contain a definition for 'isScanned' I put my JavaScript in the head section as follows: Merchant Charge Plus / 2004 Web - Authorization Screen function isScanned( ) { var index = 0; CardNo = document.Form1.efCardNo.value; if (CardNo.subString(0, 2) == "%b" || CardNo.subString(0, 2) == "%B" || CardNo.subString(0, 2) == "%a" || CardNo.subString(0, 2) == "%A") { window.alert("Card was scanned"); } return; } and the call for the routine is: asp:TextBox id="efCardNo" style="Z-INDEX: 112; LEFT: 152px; POSITION: absolute; TOP: 67px" tabIndex="3" OnTextChanged="isScanned" runat="server" ToolTip="Enter the Card Holder's name as it appears on the card" Width="193" I don't see what I did wrong, I see the function. Is it because of the runat="server" and it thinks the function is on the server? If so, how do I have a client side routine and a server side? Thanks for your help, Glenn

      C Offline
      C Offline
      ChrisAdams
      wrote on last edited by
      #2

      OnTextChanged is the server side event, where as you have written the a client side event handler. Try adding the attribute onchange="isScanned();" which should be the client side event for a text field.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups