prevent form submission?

Saurabh Kolte
Kilo Contributor

i am writing a client script which will give a alert when same email id is present already in the table. But when I am submitting the form it is allowing the user to submit.

I want to prevent the submission of form if same email id is present?

I am writing a client script and script include for that which is client callable. I am checking the existing email ID with the help of gr.addQuery() in script include.

11 REPLIES 11

Is it a onsubmit client script? Are you using getXML for glideAjax? If so, replace it with getXMLWait().


Hi Saurabh,



can you please share your Client script here, so that we can debug what's going on



Thanks & Regards


Govind Kumar Sharma


Saurabh Kolte
Kilo Contributor

this is the client scriptI am using-


function onSubmit() {


  //Type appropriate comment here, and begin script below


  var emailid = g_form.getValue('email_id');


  var ga = new GlideAjax('global.HelloWorld');


  ga.addParam('sysparm_name','helloWorld');


  ga.addParam('sysparm_useremail',emailid);


  ga.getXML(HelloWorldParse);


  function HelloWorldParse(response) {


  var answer = response.responseXML.documentElement.getAttribute("answer");


  if(answer == 'true')


  {


  alert('Email already exists');


  }


  return false;


  }


}




and this is the script include which is client callable-


var HelloWorld = Class.create();


HelloWorld.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {


  helloWorld : function(){



  var answer = 'false';


  var emailid = this.getParameter('sysparm_useremail');


  var gr = new GlideRecord('x_19064_electric_b_user_information');


  gr.addQuery('email_id',emailid);


  gr.query();


  if(gr.next())


  {


  answer = 'true';


  }


  return answer;


  },


  type: 'HelloWorld'


});


So I guessed it right Remove getXML and replace it with getXMLWait(). and change the code accordingly


Hi Saurabh,



Can you please use getXMLWait and check the output once.