smares32371
asked on
javascript IF on radio button value
I have a radio group, bill 3 radio buttons
values:
a
b
c
I could ge the radio button value.
On the c value i want to do a javascript if() to validate the credit card fields only if radio button with the c value is selected
New-Text-Document--6-.txt
values:
a
b
c
I could ge the radio button value.
On the c value i want to do a javascript if() to validate the credit card fields only if radio button with the c value is selected
New-Text-Document--6-.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
leakim971: ok its working how do i validate the rest of the credit card fields, there is like 10 more
DON'T do credit card validation only on the client side !!
Some links :
http://javascript.internet.com/forms/val-credit-card.html
https://www.experts-exchange.com/questions/21685834/Credit-Card-Number-Validation.html
http://tinyurl.com/4b7gdmf
PHP : http://tinyurl.com/4lffpeq
Some links :
http://javascript.internet.com/forms/val-credit-card.html
https://www.experts-exchange.com/questions/21685834/Credit-Card-Number-Validation.html
http://tinyurl.com/4b7gdmf
PHP : http://tinyurl.com/4lffpeq
ASKER
I just want to make sure that the credit card fields are filled in .
line 21 :
we check the field have one char (>0)
if you want 10 charactere or more :
return field.value.length>0;
we check the field have one char (>0)
if you want 10 charactere or more :
return field.value.length>=10;
ASKER
I meant I want 2 other fields to give alerts if they not filled in
close the question, award points (or not), try to understand the code, create a new question if you encounter difficulties
ASKER
i do understand the code but it only allows you to validate one field if the third radio button is selected lets forget about credit card fields, in general how would i validate normal fields base on the third button when there is more than one field.
what do you mean by validate ? Not empty ? Check the length propertie of its value (a string)
var myField_Value = document.getElementById( myField_ID ).value;
var myField_Is_Filled = myField_Value.length > 0; // this return true or false
with a field like this one :
to validate multiple fields : return myField1_Is_Filled && myField2_Is_Filled && myField3_Is_Filled;
var myField_Value = document.getElementById( myField_ID ).value;
var myField_Is_Filled = myField_Value.length > 0; // this return true or false
with a field like this one :
<input type="text" id="myField_ID" name="myField_Name" />
to validate multiple fields : return myField1_Is_Filled && myField2_Is_Filled && myField3_Is_Filled;
ASKER
yes not empty
Let me know if you code base for this.
Please no points for this comment of mine, since if @leak's reply works, he deserve all points :)