首页 \ 问答 \ 验证多重电子邮件地址(validation for multipe email addresses)

验证多重电子邮件地址(validation for multipe email addresses)

为了通过在文本字段(多文件电子邮件地址)中提供他们的邮件地址来邀请新用户,我需要验证给定的电子邮件地址格式并需要显示正确的错误消息。这里我使用的是每个电子邮件地址之间的空格。(例如useremail@gmail.com useremail2@yahoo.com )请指导我。

1)如何验证用户电子邮件地址格式?

2)如何检查用户是否在两个电子邮件地址之间没有使用空间?

3)建议一些最好的方法来做到这一点。

我正在使用rails(2.3.X和ruby 1.8.7)

用户控制器

def invite_users
  if request.get?
    #render invite_users.html.erb
  elsif request.post?
    if !params[:email_ids].blank? && !params[:message].blank?
      @email_ids = params[:email_ids].split(/ |, |,/)
      @message = params[:message]
      @inviting_users = @email_ids.count
      @inviting_users.times do
        @all_emails = []
        @all_emails = @email_ids.shift
        activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join)
        UserNotifier.deliver_invite_users(@all_emails, @message,activation_code, current_company)
        end
     else
       flash[:notice] = "Please fill all the fields"
     end
  end
end

For inviting the new user by giving their mail addresses in text field(multipe email addresses), i need to validate the given email addresses format and need to show the proper error message.Here i am using the space between the each email addresses.(for example useremail@gmail.com useremail2@yahoo.com)Please guide me.

1)How to validate user email addresses format?.

2)How to check if the user doesn't use space between the two email addresses?.

3)Suggest some best way to do this.

i am using rails(2.3.X and ruby 1.8.7)

User controller

def invite_users
  if request.get?
    #render invite_users.html.erb
  elsif request.post?
    if !params[:email_ids].blank? && !params[:message].blank?
      @email_ids = params[:email_ids].split(/ |, |,/)
      @message = params[:message]
      @inviting_users = @email_ids.count
      @inviting_users.times do
        @all_emails = []
        @all_emails = @email_ids.shift
        activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join)
        UserNotifier.deliver_invite_users(@all_emails, @message,activation_code, current_company)
        end
     else
       flash[:notice] = "Please fill all the fields"
     end
  end
end

原文:https://stackoverflow.com/questions/12314913
更新时间:2022-04-10 08:04

最满意答案

我并不是特别熟悉android但是如果我记得正确的OpenGL C绑定没有Bitmap结构。 相反,各种位图函数(即glBindTexture() )只需要使用GLuint指针(C等效于数组)。

在Java中,所有东西都是一个类,所以位图有一个与之关联的类,但是位图类主要只是实际包含图像的int数组的包装器(以及一些函数)。

特别是在OpenGL中,我们经常使用glBindTexture函数绑定一个数组,然后其他纹理函数采用它所绑定的名称来引用OpenGL的正确“状态”。

另一方面,如果您尝试短路此过程,您可以始终使用glTexImage2D


I am not specifically familiar with android but if I remember by OpenGL C bindings properly there is no Bitmap structure. Instead the various bitmap function (i.e. glBindTexture()) just take GLuint pointers (the C equivalent of an array).

In Java everything is a class so the bitmap has a class associated with it, but the bitmap class is mostly just a wrapper (and some functions) for the int array which actually contains your image.

In OpenGL specifically, we often times bind an array with the glBindTexture function, and then other texture functions take the name it's bound to to reference the correct 'state' for OpenGL.

On the other hand if you are trying to short circuit this process you can always use glTexImage2D

相关问答

更多
  • 在某些时候,您只能通过在Opengl中定义3D顶点来处理复杂对象。 相反,您需要可以将其包含在项目中的对象模型。 大多数对象模型都带有纹理文件和纹理坐标,因此您无需担心纹理化。 为了将对象加载到场景中,我建议你使用assimp库。 在设置环境之后,您只需要搜索免费的低多边形树模型。 这是一个网页,你可以找到免费的低聚树: http : //www.loopix-project.com/ After some point, you cannot handle complex objects by just d ...
  • 您需要将这些bytes放入MemoryStream : Bitmap bmp; using (var ms = new MemoryStream(imageData)) { bmp = new Bitmap(ms); } 这使用Bitmap(Stream stream)构造函数重载。 更新:请记住,根据文档以及我一直阅读的源代码,在这些条件下将抛出一个ArgumentException : stream does not contain image data or is null. -or- st ...
  • 四件事: 一,是的,就是你如何制作一个指向数组的指针。 请注意,指向整数的指针和指向整数数组的指针之间没有区别; 您可以将整数视为一个元素的数组。 如果x是指向整数的指针,你仍然可以使用x[0]如果x是指向数组的指针,你仍然可以使用*x ,它们的工作方式相同。 其次,你必须使用delete[] theName , 而不是 delete theName 。 无论你在哪里使用new你都必须使用delete ,无论你在哪里使用new[]你都必须使用delete[] 。 此外,没有必要设置theName = NUL ...
  • 我并不是特别熟悉android但是如果我记得正确的OpenGL C绑定没有Bitmap结构。 相反,各种位图函数(即glBindTexture() )只需要使用GLuint指针(C等效于数组)。 在Java中,所有东西都是一个类,所以位图有一个与之关联的类,但是位图类主要只是实际包含图像的int数组的包装器(以及一些函数)。 特别是在OpenGL中,我们经常使用glBindTexture函数绑定一个数组,然后其他纹理函数采用它所绑定的名称来引用OpenGL的正确“状态”。 另一方面,如果您尝试短路此过程,您 ...
  • 请记住, tokens是指针指针类型, char **tokens 。 因此*(tokens+i)是一个指针。 您正在将该指针(对于字符串)视为整数。 您需要做的是首先将字符串转换为整数类型。 strtoul()是一个很好的起点。 您甚至可以指定基数,因此它会自动从十六进制转换。 for (i = 0; tokens[i]; i++) { char *endptr; unsigned long tmp; printf("val=[%s]\n", tokens[i]); tmp ...
  • Baisc OpenGL不管理鼠标事件,你应该选择GLUT或SDL来实现用户输入控制。 编辑:正如Vallentin在他的评论中指出的那样,GLUT已经过时了,并建议看看GLFW 。 Baisc OpenGL does not manage mouse events, you should go for GLUT or SDL to achieve user input control. EDIT: As Vallentin points out in his comment, GLUT is outdat ...
  • 您可以使用reinterpret_cast ,然后使用相同的方法将其转发回接收方。 you can use reinterpret_cast and then cast it back at receiver side using same.
  • 事实证明这是SharpGL的问题 - 我正在使用的OpenGL库。 http://sharpgl.codeplex.com/discussions/348278 - 对CodePlex的讨论导致SharpGL开发人员解决了这个问题。 This turned out to be an issue with SharpGL - the OpenGL library I was using. http://sharpgl.codeplex.com/discussions/348278 - discussion o ...
  • 如果我理解你正在做什么,听起来问题不是真正的纹理。 这是你添加的填充,以达到不透明的二次幂。 我最初认为你没有清除整个位图,但你有c.DrawColor()调用应该处理。 可以肯定的是,您可以在创建位图后立即尝试以下操作,并查看它是否有所不同: b.eraseColor(Color.TRANSPARENT); 我能想到的另一种方法是更清洁和更好:在渲染过程中,不要使用您添加的纹理部分来填充大小。 您可以通过调整纹理坐标来仅对包含视图的纹理部分进行采样。 使用示例中的尺寸(绘制到512x512纹理中的300 ...
  • 图像为空修复: var fos = new FileOutputStream(filePath); //fos.Write(new byte[buffer.Remaining()]); byte[] bmpData=new byte[buffer.Position()]; buffer.Position(0); //or buffer.Flip(); buffer.Get(bmpData, 0, buffer.Remaining()); fos.Write(bmpData); fos.Close ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。