Web Analytics Made Easy -
StatCounter form field validation - CodingForum

Announcement

Collapse
No announcement yet.

form field validation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • form field validation

    Hello, we created and online application with full validation on all fields, now we need to have 4 of the fields not required..can anyone help me out with code for this?
    What do you need to see of my code to help?
    Thank you,
    Nick

  • #2
    How are you doing the validation? ASP or Javascript? Post your code here and let us know what fields you want to ignore and we can probably help you.

    Comment


    • #3
      here the validation code, let me know what else you need.

      /*


      One of the fields I need to remove req validation is called position2 , so if you could help me with the code for that one, I think I could take it from there.
      hopefully..lol
      thank you


      '------------------------------------------------+
      ' |
      ' |
      ' |
      ' Generic JavaScript Functions Library |
      '------------------------------------------------+
      */

      // global variables
      ElementArray = new Array();
      PromptArray = new Array();

      // function definitions
      var dont;
      dont = 'Your application is now being submitted. Please do not refresh the page or submit the form again';


      function FormSubmit(obj){
      if (obj) {
      if (navigator.appName.indexOf('Microsoft')==-1) {
      eval('window.frames.document.'+obj+'.submit()');
      }
      else {
      eval('window.document.'+obj+'.submit()');
      }
      } // end test for form
      }

      function Validate (a,b){
      var s= ElementArray.length;
      ElementArray[s] = a;
      PromptArray[s] = b;
      }

      function Check(obj) {
      var tmp='';
      var s='';
      var y='';
      var m= obj.elements.length;
      var thisRadioChecked;

      // go thru list
      for (var k=0;k<m;k++){
      e = obj.elements[k];

      if (Pos(ElementArray, e.name)>-1){
      if (ElementArray[e.name]!=''){

      y=e.type;
      if (y=='radio') {
      var r= obj.elements[e.name];
      thisRadioChecked=false;
      for(var i=0;i<r.length;i++){
      if(r[i].checked){thisRadioChecked=true};
      }
      if (!thisRadioChecked){
      tmp=PromptArray[Pos(ElementArray, e.name)];
      break;
      }
      }
      else
      {
      if(y=='checkbox') {
      if (!(e.checked)){
      tmp=PromptArray[Pos(ElementArray, e.name)];
      break;
      }

      }
      else{

      s=e.value;
      if ((s=='undefined')||(s=='')||(s=='null')){
      tmp=PromptArray[Pos(ElementArray, e.name)];
      break;
      }
      }
      }

      }
      }
      }
      if (tmp!='')
      {alert(tmp)}
      else
      {alert(dont)}
      return (tmp=='');
      }

      function Pos(ar, val) {
      var ret=-1;
      var mlen= ar.length;
      for (var klen=0;klen<mlen;klen++){
      if(ar[klen]==val)
      {
      ret=klen;
      break;
      }
      }
      return ret;
      }

      Comment

      Working...
      X