Register  |  Login




Advertisement

Start Your Own Q&A Site

Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.

Question

Status: Open Points: 125 Time: 10:54 - Apr 27, 2010  

mkronix

multiple group of radio buttons validation

hi guys, i have a form with input text, dropdown menu and groups of radio button. the validation for input text and dropdown menu works fine with these js validator -

<script language="JavaScript">
function formValidator(){

// Make quick references to our fields

 var pensyarah = document.getElementById('pensyarah');
 var kksem = document.getElementById('kksem');



 // Check each input in the order that it appears in the form!
if(madeSelection(pensyarah, "Sila pilih Pensyarah")){
 if(madeSelection(kksem, "Sila pilih Kod kursus")){



 return true;
 }
 }


 return false;

}



function isEmpty(elem, helperMsg){
 if(elem.value.length == 0){
  alert(helperMsg);
  elem.focus(); // set the focus to this input
  return true;
 }
 return false;
}

function isNumeric(elem, helperMsg){
 var numericExpression = /^[0-9\s\:]+$/;
 if(elem.value.match(numericExpression)){
  return true;
 }else{
  alert(helperMsg);
  elem.focus();
  return false;
 }
}

function isAlphabet(elem, helperMsg){
 var alphaExp = /^[a-zA-Z\s\.]+$/;
 if(elem.value.match(alphaExp)){
  return true;
 }else{
  alert(helperMsg);
  elem.focus();
  return false;
 }
}

function isAlphanumeric(elem, helperMsg){
 var alphaExp = /^[0-9a-zA-Z\s]+$/;
 if(elem.value.match(alphaExp)){
  return true;
 }else{
  alert(helperMsg);
  elem.focus();
  return false;
 }
}

function madeSelection(elem, helperMsg){
 if(elem.value == "*Tiada Pilihan"){
  alert(helperMsg);
  elem.focus();
  return false;
 }else{
  return true;
 }
}


function emailValidator(elem, helperMsg){
 var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
 if(elem.value.match(emailExp)){
  return true;
 }else{
  alert(helperMsg);
  elem.focus();
  return false;
 }
}


</script>

my question is.. how to do the group of radio button validation inside the existing js validator.. is it posible to merge it in one function?

this is my form code:
http://www.modernessence.net/e1flashz/im...

this is how the form looks like
http://www.modernessence.net/e1flashz/im...

any ideas..

Thank you in advance.

(sorry for my english, i'm from malaysia)



Answer Discussion
Tutorials

 

This question has not yet been answered.

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

Tutorials cannot be submitted until the Answer Discussion is complete.

Submit answers in the Answer Discussion area

Ask a Question

Have a new question? Ask!

You have 100 characters to use



Top Experts

View More

Rank

Expert

Points

1.

nidhi

10279

2.

oracleofDelphi

6493

3.

rcastagna

5596

4.

LAGM

4848

5.

PeterNZ

3487

6.

gonzalo

2840

7.

Mason

2770

8.

jgivoni

2303

9.

xarcus

1820

10.

Anpanman

917

Become an Expert

Register today to share your knowledge with the community and be recognized and rewarded for your contributions.


Register Here




"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it



Language Options

English:

www.quomon.com

Español:

www.quomon.es