Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-08-2011, 07:51 PM   PM User | #1
DanInMa
Senior Coder

 
DanInMa's Avatar
 
Join Date: Nov 2010
Location: Salem,Ma
Posts: 1,336
Thanks: 13
Thanked 207 Times in 207 Posts
DanInMa is on a distinguished road
Question small Jquery form submittal/reset issue

I'm including a portion of the code I use on form submittal. I have 2 radio buttons and a user must select one of these options or the form will not submit ( see green code) . I wrote a check to ensure that at least one radio is checked off or they get an error and it hightlights the radio boxes. This works fine , the first time. Once the submittal passes the checks I have put in it, the data is submitted via ajax and this resets most of the form , including unchecking the radio boxes ( shown in red) . The problem is that if a user wants to then submit another request via the form , even when they check off a radio box, it is not passing the "if not checked" code

Code:
if ( $("#scheduling_1").attr('checked') == false && $("#scheduling_0").attr('checked') == false ){
    	$("#scheduling_1,#scheduling_0").addClass('inputBG-error');
	data1++  
  }
  
  if(data1 > 0 ){
	$("#control").removeClass('inputBG-error');
            msg1.append("<div class='blk-border'><p class='red'>You have left some information blank.</p><p> Please fill out any fields highlighted in red and try again.</p></div>");
	  }

if(data1 > 0 ){
$("#submit-response").html(msg1).delay(250).show("slow");
return false
	  }

		//Form submittal to server via Jquery .Ajax call begins here
	var datastring = $('#rzrequestform').serialize();
    $.ajax({
        type: "POST",
        url: "/Subwebs/Information Services/HelpDesk/rz/rzredzoneprocessUser.asp",
        data: datastring,
        success: function(html){
		var tt=  $(html).find("#hidden").text();
			var msg = $("<div id='request-reply'></div>"); 
			if ( $('#ticket').is(':checked')) {
			  msg.html("<div class='blk-border'><p>Your RedZone request has been submitted to the HelpDesk.</p><p class=\"red\"><strong>Your Redzone ID # is: "+tt+"</strong></p><p>You should save this number in case you would like to request any changes or updates to the notice you have requested.</p><p><a href='/Subwebs/Information Services/HelpDesk/scticket.asp'>Click here to open a web ticket also.</a></p></div>");			  
			}
			else {
			msg.html("<div class='blk-border'><p>Your RedZone request has been submitted to the HelpDesk.</p><p class=\"red\"><strong>Your Redzone ID # is: "+tt+"</strong></p><p>You should save this number in case you would like to request any changes or updates to the notice you have requested.</p></div>");						
			}
			
		   $('input,textarea,#legend').removeClass('inputBG-error')
		   $(':input','#rzrequestform').not(":button, :submit, :reset, :hidden,[name='requestername'],[name='requesterusername']").val("")
		  $('#scheduling_1,#scheduling_0').removeAttr('checked');	
		   
		   $("#submit-response").html(msg).delay(250).show("slow");
			},
DanInMa is offline   Reply With Quote
Old 04-13-2011, 05:49 PM   PM User | #2
DanInMa
Senior Coder

 
DanInMa's Avatar
 
Join Date: Nov 2010
Location: Salem,Ma
Posts: 1,336
Thanks: 13
Thanked 207 Times in 207 Posts
DanInMa is on a distinguished road
nevermind I fixed it. I was inadvertantly clearing the values of the radio boxes in my form reset function. I had to change this:


Code:
$(':input','#rzrequestform').not(":button, :submit, :reset, :hidden,[name='requestername'],[name='requesterusername']").val("")
		  $('#scheduling_1,#scheduling_0').removeAttr('checked');
to this:

Code:
$(':input','#rzrequestform').not(":button, :submit, :reset, :hidden,[name='requestername'],[name='requesterusername'],[name='scheduling']").val("")
		  $('#scheduling_1,#scheduling_0').removeAttr('checked');
DanInMa is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:01 AM.


Advertisement
Log in to turn off these ads.