JS Var With Hyphen = NaN

Mar 27, 2003

I am sending credit card information to a merchant account script. The documentation for the MA states the variable names it requires, things like card-type, card-number, card-exp. So I have input fields for each.

The problem is my JS validation function will not recognize these variables if they have a hyphen. If I change the hyphen to underscore, the function will recognize them, ex:
<input type="text" name="card-number">
<input type="text" name="card_number">

alert(document.frm.card-number.value);//NaN
alert(document.frm.card_number.value);//works

I can not change the field names to use underscores because the payment script is looking for the hyphen variable name. Anyone know how I can get the values of these fields with hyphens?

View 3 Replies


ADVERTISEMENT

Cannot Pass Parameters Containing Hyphen(-) - Dot(.)

Jun 13, 2009

I am trying to pass dynamic String parameter to my javascript. The user enters sdome value and that is passed to the javascript as parameter. My problem is when user enters something of type cs204-1 or cs204.1 etc, the javascript does not run. On passsing simple parameters like cs204 or 111 etc, the javascript works fine. I need to pass any type of parameters to the javascript ( cs204-1 or cs204.1 etc) as I am making this for my college and the values to be entered by the user are of such type. My javascript code is : Code:

[Code]...

I tested the working of the javascript by using alert. It came for normal parameters but not for cs204-1 or cs204.1 types.

View 3 Replies View Related

Pre Defined Hyphen As Variable Name?

Jun 17, 2010

I am currently working with a cms system that doesnt keep within the correct name conventions (pre defined).Within a form, I simply want to set a date to todays date:

<script type="text/javascript">
function initdt(mf) {
var t = new Date;

[code]...

This works perfect on a form I create, but sadly I must use a form within a pre defined system that uses "01-date" Is there a way around this? A simple way of setting 01-date to t.getDate();

View 2 Replies View Related

Match All Integers Before And After The Hyphen?

Feb 24, 2010

I'm trying to match all integers before and after the hyphen:

12345-5

This is what I tried but always returns null

Code:

var divID = '12345-5';
var idPattern = /^[0-9]+$/; //Matching one or more numbers before the hyphen
var id2Pattern = /^-[0-9]+$/; //Matching starts from the hyphen and all numbers that proceed

[code]....

View 4 Replies View Related

Cannot Pass Parameters Containing Hyphen / Dot

Jun 13, 2009

I am trying to pass dynamic String parameter to my javascript. The user enters sdome value and that is passed to the javascript as parameter. My problem is when user enters something of type cs204-1 or cs204.1 etc, the javascript does not run. On passing simple parameters like cs204 or 111 etc, the javascript works fine. I need to pass any type of parameters to the javascript ( cs204-1 or cs204.1 etc) as I am making this for my college and the values to be entered by the user are of such type.

My javascript code is :
function deleteQuestion(id){
alert(id);
questionId= eval("document.form1.deleteQ"+id+".value");
url='/DeleteQuestionServlet?questionId='+escape(questionId);
document.form1.action=url;
}
I tested the working of the javascript by using alert. It came for normal parameters but not for cs204-1 or cs204.1 types.

View 1 Replies View Related

Username Verification - Accept Only A-z0-9 And _(underscore),-(hyphen) And .(dot)

Jul 19, 2011

I have written a function for accepting name and should be atleast minimum 4 characters. It is accepting all characters including special characters. Now i want my function to accept only a-z0-9 and _(underscore),-(hyphen) and .(dot) Below is my function

[Code]...

View 24 Replies View Related

How To Include Dot / Hyphen In Name Section Of Email Address

Jul 21, 2010

This is the regular expression I currently have
/^(w+|w+.w+)@(w+|w+-w+).(w{2,3}|w{2,3}.w{2,3})$/;
The script dates from about 2006. The script is ok for emails that just contain a "dot" before the @, as in: joe.bloggs@home.com

What needs to be changed in the above script to allow both these types of email?
joe.bloggs@home.com and
joe.bloggs-smith@home.com

View 2 Replies View Related

Zip Code Validation / Formatting - Adding Hyphen Automatically

Feb 7, 2011

I need US zip code formatting on my page. As zip code can be 5 digits or 5-4 digits, our requirement is that when user types in 6th digit, hyphen automatically gets added between 5th and 6th digit. Ex: user enters 100161, it should become formatted as 10016-1 and then user can continue to add rest of digits.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved